Jump to content

Checking if a sprite overlap an other during its creation


Me.question();
 Share

Recommended Posts

Hello,

i have this code that should create in the create function if one of the sprites of the "asteroids" group is overlapping the station (so the player doesnt get instant killed when he spawn).

It is working in the Asteroid.prototype.update function but to optimize the game i would like to check it in the create function.

this.asteroids.forEach(function (item) {
			if (Phaser.Rectangle.intersects(this.station.getBounds(), item.getBounds())) {
				item.destroy();
			}
			
		}, this);

It isnt working as exepted, could soweone help me ?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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