A newbie question but as hard as I have searched I have not been able to find a way to animate a sprite only while moving then when move complete return to original standing frame. Animation is a walk.
this.sprite = new cc.Sprite.create("#player-stand");
this.sprite.setPosition(new cc.Point(300,300));
this.addChild(this.sprite);
var animFrames = [];
var str = "";
for (var i = 0; i < 5; i++) {
str = "player-walk" + i;
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(str);
var animFrame = new cc.AnimationFrame();
animFrame.initWithSpriteFrame(spriteFrame, 1, null);
animFrames.push(spriteFrame);
}
var animation = cc.Animation.create(animFrames, 0.025);
var animate = cc.Animate.create(animation);
sprite_action = cc.MoveTo.create(2,cc.p(x,y));
var seq = cc.Sequence.create(animate, sprite_action);
this.sprite.runAction(seq);
I have tried RepeatForever on the animation but I get a debugger message in the console:[Action update]. override me CCDebugger.js:335
var animate = cc.RepeatForever.create(cc.Animate.create(animation));