正确
var tmpShip3 = cc.Sprite.createWithSpriteFrameName("w1_1.png"); tmpShip3.setPosition(250,180); this.addChild(tmpShip3); var animFrames3 = []; // 将所有帧存入一个数组 for (var i=1;i<=4;i++) { //采用循环添加动画的每一帧 var strPngName3 = "w1_" + i + ".png"; var frame3 =cc.SpriteFrameCache.getInstance().getSpriteFrame(strPngName3); if (frame3) { animFrames3.push(frame3); } } var animation3 = cc.Animation.create(animFrames3, 0.01); tmpShip3.runAction(cc.RepeatForever.create(cc.Animate.create(animation3))); tmpShip3.runAction(cc.MoveTo.create(3, cc.p(250 ,winSize.height)));
无效
tmpShip3.runAction( cc.Spawn.create( cc.RepeatForever(cc.Animate.create(animation3)), cc.MoveTo.create(3, cc.p(250 ,winSize.height)) ) );
有效,只动一次
tmpShip3.runAction( cc.Spawn.create( cc.Animate.create(animation3), cc.MoveTo.create(3, cc.p(250 ,winSize.height)) ) );