Jump to content

Update not being called automatically


scottgroovez
 Share

Recommended Posts

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

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().

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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