jevisan Posted February 23, 2016 Share Posted February 23, 2016 Hello, i'd like to know if there's any way to determine if a certain sprite is part of a certain group. More specifically, if i can check for collision between sprite and group, and make sure the sprite is colliding with another sprite that's part of a certain group. Thanks in advance. Link to comment Share on other sites More sharing options...
drhayes Posted February 23, 2016 Share Posted February 23, 2016 If you want to check collision and you're using Arcade then you can call game.physics.arcade.collide(sprite, group). It'll return true if they collided. You can also supply a collisionCallback that will be called with the two sprites that collided. You should also check out "overlap". But I get the feeling that's not quite what you're asking..? Or maybe it is? Link to comment Share on other sites More sharing options...
jevisan Posted February 24, 2016 Author Share Posted February 24, 2016 @drhayes not quite. I'm asking for a way to check if a sprite is part of a given group, maybe a way to handle that in the collide callback function? like checking if one of the sprites was part of group A or group B. Link to comment Share on other sites More sharing options...
fillmoreb Posted February 24, 2016 Share Posted February 24, 2016 Try something like this: if(groupA.children.indexOf(sprite) > -1) { // sprite is a part of groupA } drhayes 1 Link to comment Share on other sites More sharing options...
jevisan Posted February 24, 2016 Author Share Posted February 24, 2016 oh, thank you so much, this will make my life so much easier. I'll try it right away fillmoreb 1 Link to comment Share on other sites More sharing options...
Recommended Posts