Jump to content

animation won't always play


Recommended Posts

hi :)


I have in my game a function that add and play an animation evrey time a new question appears. 


        this.door_open.alpha = 1;
        this.door_close.alpha = 0;
            console.log("door is open!");
I don't know why, but the animation happens evrey time I call the function, however sometimes the sprite won't update. 
any idea?
Link to comment
Share on other sites

You have to add the animation only once, then you can play whenever you want. Do this inside the state create method.

// add the animation once in the create methodcreate: {  this.door_open.animations.add('run').onComplete.add(function(){    console.log("door is open!");  },this);},// call play each timeplayAnimOpen:function(){  this.bringDoorToTop();  this.door_open.alpha = 1;  this.door_close.alpha = 0;  this.door_open.animations.play('run', 20,false);},
Link to comment
Share on other sites


  • Recently Browsing   0 members

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