Jump to content

Physics.arcade.overlap only one time


Recommended Posts

Hi Phaser users.

I have an problem with overlap function.

Overlap created in update, so it run every frame. But problem is that overlap happens over ten times while sprite moving through it.

How can I code that if sprite overlap with other object, they will never overlap again?

I think about killing object that overplap with sprite, and then copy his attributes to other object that wont overlap with sprite. Maybe you will suggest better solution.

create: function() {				// Add player to scene	this.poring = this.add.sprite(60, 128, 'poring');	this.physics.arcade.enable(this.poring);	this.poring.body.bounce.y = 0;	this.poring.body.gravity.y = 800;	this.poring.body.collideWorldBounds = true;	this.poring.animations.add('run', [0,1,2,3,4], 10, true);	this.poring.animations.play('run');				// Bush	this.bushes = this.add.group();	this.bushes.enableBody = true;	this.bushes.createMultiple(10, 'prontera_bush');},update: function() {	// Overlap poring and bush	this.physics.arcade.overlap(this.poring, this.bushes, this.lose, null, this);},// This will be triggered a lot of timeslose: function(poring, bush) {	this.state.start('GameOver');},
Link to comment
Share on other sites

  • 6 months later...

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...