Jump to content

Colliding groups - which object collided?


Recommended Posts

Hi all!


I'm just starting out and I can't figure this out. I'm building a space shooter and I'd like the asteroids to rotate at different speeds but to also have a shade that is fixed. I did this by creating two sprite groups, where the shade is translucent and on top of the asteroid. I'm colliding the asteroid with a laser group, but I need to remove both the asteroid AND the shade upon collision/overlap. You can see the "game" here:



Since both groups are the same size, if I knew which sprite was hit, I could simply remove it from the other group as well, but I don't know if there's a way to find that out.




When colliding/overlapping two groups, is there a way to find out which object collided?

Link to comment
Share on other sites



If you are using Arcade physics you can use this in your render functions.



//in render function


        this.game.debug.body(whatever sprite you want to debug);
this will show you the sprites body that is colliding, if you want to see how multiple sprites are colliding just use multiple debugs in your render function.
Hope this helps! Let me know.
Link to comment
Share on other sites


  • Recently Browsing   0 members

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