Jump to content

Sprite and group children update never called


swemaniac
 Share

Recommended Posts

Hello,

 

I've been searching around for an explanation/answer for this but I can't find anything definitive so here goes.

 

If I add a sprite as a child to another sprite via Sprite.addChild(), the child's update() method is never called.

If I add the child sprite to a Group which has a Sprite set as parent, the child's update() method is also never called.

 

I've seen hints about this being "expected behavior" and/or related to Pixi but is it really? And why?

 

Thanks

Link to comment
Share on other sites

Sprite.update will only be called if it's a child of a Group. Under no other circumstance will it be called. It's also an entirely empty function, update doesn't actually do anything, it's purely there for you to override.

 

So if you need a Sprite to update its children, then override its update function and code in whatever conditions you need to make that the case.

 

Oh and no, this is nothing to do with Pixi.

Link to comment
Share on other sites

I think sprites have an empty update method for you to extend yourself http://www.html5gamedevs.com/topic/1925-how-to-write-a-class-that-extends-from-phasersprite/

 

groups explicitly call update on their children  https://github.com/photonstorm/phaser/blob/master/src/core/Group.js#L1372

 

you could implement that yourself on a custom Sprite I guess

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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