scottgroovez Posted February 15, 2016 Share Posted February 15, 2016 Hi, I have a state that creates two instances of a class that extends the group class. In this subclass I create an instance of a class that extends the sprite class. StudyState (state) StudyArea (group) PaintPot (sprite) However, update in the PaintPot class doesn't get called automatically. I need to call its update method from within the update method of the StudyArea. Any clues as to what I'm doing wrong or better ways of architecturing this? StudyArea.prototype.update = function() { this.paint_pot.update(); } Cheers in advance! Link to comment Share on other sites More sharing options...
Tom Atom Posted February 15, 2016 Share Posted February 15, 2016 Hi, this is Phaser source (file Group.js) for Group update(): /** * The core update - as called by World. * @method Phaser.Group#update * @protected */ Phaser.Group.prototype.update = function () { var i = this.children.length; while (i--) { this.children.update(); } }; So, child's update() method should be called ... unless you have overridden Groups's update() method in your derived class (StudyArea). If your StudyArea has its own update method, then it is skipping default implementation. You can then either copy this simple loop and call children by yourself or call super implementation in the end of your StudyArea update(). Francisco and scottgroovez 2 Link to comment Share on other sites More sharing options...
scottgroovez Posted February 23, 2016 Author Share Posted February 23, 2016 Thanks, I did indeed have an update method in my group. Removing this has solved the problem. Link to comment Share on other sites More sharing options...
Recommended Posts