ActionManager

来源:互联网 发布:淘宝爆款推广计划 编辑:程序博客网 时间:2024/06/05 04:03

1. 运行场景

(1) 初始化场景(2)加入层(3)运行场景

        var s = new ActionManagerTestScene();        s.addChild(previousActionMgrTest());        director.runScene(s);
2.层onEnter

初始化精灵

var child = cc.Sprite.create(s_pathGrossini)
指定精灵位置,并加入层

child.x  = 200;child.y = 200;this.addChild(child, 1)

精灵运行动作,1.5s旋转90度,延迟1.4s执行1.1淡出

child.runAction(cc.RotateBy.create(1.5,90));child.runAction(cc.Sequence.create(cc.DelayTime.create(1.4), cc.FadeOut.create(1.1)));
延迟1.4s后回调函数
this.runAction(cc.Sequence.create(            cc.DelayTime.create(1.4),            cc.CallFunc.create(this.onRemoveThis, this))        );
3.其他动作

node.runAction(cc.ScaleTo.create(2, 2));

执行动作后回调函数

grossini.runAction(cc.Sequence.create(            cc.MoveBy.create(1, cc.p(150, 0)),            cc.CallFunc.create(this.onBugMe, this))        );
4.精灵停止所有动作

sprite.stopAllActions()

5.使用actionManager加入动作,第三个参数true表示不立即播放

        var action = cc.MoveBy.create(1, cc.p(150, 0));        director.getActionManager().addAction(action, grossini, true);
6. schedule使用

this.schedule(this.onUnpause, 3);
this.unschedule(this.onUnpause);

7.根绝Tag获取子节点

var node = this.getChildByTag(TAG_GROSSINI);
8. 将节点pasused属性置为false

director.getActionManager().resumeTarget(node);
9. 根据序列tag移除动作

 var move = cc.MoveBy.create(2, cc.p(200, 0));        var callback = cc.CallFunc.create(this.stopAction, this);        var sequence = cc.Sequence.create(move, callback);        sequence.tag = TAG_SEQUENCE;        var child = cc.Sprite.create(s_pathGrossini);        child.x = 200;    child.y = 200;        this.addChild(child, 1, TAG_GROSSINI);        child.runAction(sequence);

stopAction:function () {        var sprite = this.getChildByTag(TAG_GROSSINI);        sprite.stopActionByTag(TAG_SEQUENCE);    },

10. 暂停节点动作,以及恢复节点动作

  grossini.runAction(cc.ScaleBy.create(2, 2));        director.getActionManager().pauseTarget(grossini);        grossini.runAction(cc.RotateBy.create(2, 360));

 var grossini = this.getChildByTag(TAG_GROSSINI);        director.getActionManager().resumeTarget(grossini);










0 0
原创粉丝点击