My Evil Pony

Check if my sprite has been overlapped by any sprites in this group

Recommended Posts

Hello guys. Please help. Is it possible to check that my sprite has been overlapped by another sprite in this group ? Something like this
 

if ( mySprite.overlap(groupOfMySprites) ) { 
 // do something with mySprite
}

Thanks for answer.

Share this post


Link to post
Share on other sites

Need to check not only collision. There is important difference beetwen sprites, that have been overlapped, and sprites, that have overlapped another sprites. Im my task i need to check if my sprite had been overlapped by any another sprite. 

Share this post


Link to post
Share on other sites

You can pass a group as the arcade physics overlap function. https://photonstorm.github.io/phaser-ce/Phaser.Physics.Arcade.html#overlap

That said, you need arcade physics on all sprites within the group as well as the sprite you want to check against the group.  If you feel you don't need physics on the group's sprites, check this example:  https://www.phaser.io/examples/v2/sprites/overlap-without-physics

Also, for future reference, you can forEach any group do custom work on each of its elements independently, just like a vanilla javascript array.

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.