Jump to content

Phaser execute collision callback only once


andreasp1994
 Share

Recommended Posts

Hey guys,

I am seeking some help on how to execute a collision callback only once. I am creating an asteroids game, but when the spacecraft collides with the asteroid the callback executes continuously.

I would like to execute the call back only once while the collision is happening and re enable it when they stop colliding. 

Is there a way to trigger a callback when the collision stops ??

Any help is appreciated.

Thanks 

Link to comment
Share on other sites

Are you using arcade.collide or arcade.overlap? collide should separate the two bodies so they collide for only 1 frame.

For arcade.overlap, Phaser doesn't trigger anything when the overlap ends, but you can track it yourself with body.touching.none and body.wasTouching.none.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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