Sprite and group children update never called

Recommended Posts



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?



Share this post

Link to post
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.

Share this post

Link to post
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

Share this post

Link to post
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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.