swemaniac Posted November 16, 2015 Share Posted November 16, 2015 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 More sharing options...
rich Posted November 16, 2015 Share Posted November 16, 2015 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. jmp909 1 Link to comment Share on other sites More sharing options...
jmp909 Posted November 16, 2015 Share Posted November 16, 2015 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 More sharing options...
jmp909 Posted November 16, 2015 Share Posted November 16, 2015 Beat me to it Rich! im glad I've actually understood it though Link to comment Share on other sites More sharing options...
swemaniac Posted November 16, 2015 Author Share Posted November 16, 2015 Okay thanks guys; I am already using custom sprites with overridden update methods and I was using addChild because it made the most sense, so I'll update the children explicitly. Link to comment Share on other sites More sharing options...
Recommended Posts