valentinaCom Posted September 4, 2014 Share Posted September 4, 2014 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 More sharing options...
eguneys Posted September 4, 2014 Share Posted September 4, 2014 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 More sharing options...
valentinaCom Posted September 4, 2014 Author Share Posted September 4, 2014 It's work! thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts