Jump to content

animation won't always play


valentinaCom
 Share

Recommended Posts

hi :)

 

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

 

playAnimOpen:function(){
        this.bringDoorToTop();
        this.door_open.alpha = 1;
        this.door_close.alpha = 0;
        this.door_open.animations.add('run').play(20,false).onComplete.add(function(){
            console.log("door is open!");
        },this);
    },
 
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

 Share

  • Recently Browsing   0 members

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