Me.question();

Checking if a sprite overlap an other during its creation

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 ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.