Jump to content

Colliding groups - which object collided?


kmajic
 Share

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:

kresimir.majic.eu/phaser_help.html

 

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.

 

 

TL; DR

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

Link to comment
Share on other sites

Hello,

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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