组合动作包括 cc.Sequence和cc.Spawn。
cc.Sequence :按顺序执行动作。把延时动作都丢进cc.Sequence里,各个动作会按顺序依次执行。
例子 :
var sprite = new cc.Sprite(sprite.png); sprite.attr({x:200, y:200}); this.addChild(sprite); var moveTo = new cc.MoveTo(2, cc.p(400,220)); var jumpTo = new cc.JumpTo(2, cc.p(400,220), 50, 3); var rotateBy = new cc.RotateBy(2, 360); var seq = new cc.Sequence(moveTo, jumpTo, rotateBy); sprite.runAction(seq);
cc.Spawn :多个动作同时执行。把延时动作都丢进cc.Spawn里,各个动作会同时执行。
例子 :
var sprite = new cc.Sprite('sprite.png'); sprite.attr({x : 200, y : 200}); this.addChild(sprite); var moveTo = new cc.MoveTo(2, cc.p(400,220)); var jumpTo = new cc.JumpTo(2, cc.p(400,220), 50, 3); var rotateBy = new cc.RotateBy(2, 360); var spw = new cc.Spawn(moveTo, jumpTo, rotateBy); sprite.runAction(spw);