Jump to content

How to get child sprite to react to dead parent sprite?


hollowdoor
 Share

Recommended Posts

When a parent is killed there is no killed event on children.

 

There's a destroy event on children so I don't understand how children don't get the other event.

 

There's an effect I want to happen on children when a parent sprite gets killed.

 

There are options I can think of like manually killing the children when the parent is killed, but I'd much rather have phaser handle the killed event.

 

Is there something I'm overlooking like maybe a property flag?

 

I'm kind of wanting the the children to be a part of the parent.

Link to comment
Share on other sites

You're not overlooking anything. Probably the best way is to setup an onKilled event on your parent sprite, then iterate each of the children in that.

 

Ok thanks. I solved it already any way. I just placed the child on a property of the parent so I could just call methods on the child sprite when the parent sprite gets killed.

 

A property works will because the effect is only on one child. It also helps because a property with no data is a good place to check if effects will happen.

 

Something else I learned is calling kill on a child sprite doesn't work, and the onKilled event can't be dispatched on the child. I suppose sprites can only really be killed directly in the game without a parent sprite. I could just add the kill method on the extended sprite, but what ever. :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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