Cocos Creator 组件-动作ActionRotate

嵌套暂时没法做,先做些常用的单独使用的动作组件

ActionRotate.js (拖到需要做该动作的节点上,不同类型的动作互不影响)

var ActionDurationRotate = cc.Class({
    name: "ActionDurationRotate",
    properties: {
        delayTime: {
            default: 0,
            displayName: "延时",
            min: 0
        },
        duration: {
            default: 1,
            displayName: "时长",
            min: 0
        },
        rotation: {
            default: 0,
            displayName: "角度",
        },
        callback: {
            default: null,
            type: cc.Component.EventHandler,
            displayName: "完成回调",
        }
    }
});

cc.Class({
    extends: cc.Component,

    properties: {
        auto: {
            default: false,
            displayName: "自动执行",
            tooltip: "如果false,则需要回调执行该脚本组件的begin方法"
        },

        delayTime: {
            default: 0,
            displayName: "自动延迟执行时长",
            tooltip: "只有在自动执行模式下,这个延迟才会有效",
            min: 0
        },

        target: {
            default: null,
            type: cc.Node,
            displayName: "执行的节点",
            tooltip: "如果没有设置就默认 挂载该脚本的节点"
        },

        startFromCurrent: {
            default: false,
            displayName: "从当前状态执行",
            tooltip: "勾上:从当前状态开始执行动作  不勾:从编辑的初始状态开始执行"
        },

        times: {
            default: 1,
            type: cc.Integer,
            displayName: "执行次数",
            tooltip: "一套动作数组 执行的次数",
            min: 1
        },

        rotateToOrBy: {
            default: true,
            displayName: "转到or转了",
            tooltip: "勾上:转动到(绝对角度);不勾: 转动了(相对角度)"
        },

        actionRotates: {
            default: [],
            type: ActionDurationRotate,
            displayName: "动作数组",
            tooltip: "暂时只支持到10个,超过了,自己进来扩写代码"
        },

        allOverCallback: {
            default: true,
            displayName: "全部完成/每完成一次回调",
            tooltip: "勾上:全部完成才回调  不勾:每完成一次都回调,执行几次就调几遍回调"
        },

        overCallbacks: {
            default: [],
            type: cc.Component.EventHandler,
            displayName: "完成回调数组"
        }
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        this.actionNode = this.target;
        if (this.actionNode == undefined || this.actionNode == null) {
            this.actionNode = this.node;
        }

        this.actionNode.srcRotattion = this.actionNode.rotation;

        if (this.auto) {
            this.scheduleOnce(function() {
                this.begin();
            }, this.delayTime);
        }
    },

    begin () {
        this.reset();
        this.currentTime = this.times;
        this.action();
    },

    reset () {
        this.currentTime = 0;
        this.actionNode.stopActionByTag(111004);
        if (this.startFromCurrent) {
            
        } else {
            this.actionNode.rotation = this.actionNode.srcRotattion;
        }
    },

    // update (dt) {},

    action () {
        if (this.currentTime > 0) {
            this.currentTime--;
        } else {
            return;
        }

        if (this.rotateToOrBy) {
            if (this.actionRotates.length == 1) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 2) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 3) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 4) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 5) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 6) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateTo(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 7) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateTo(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateTo(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 8) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateTo(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateTo(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateTo(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 9) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateTo(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateTo(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateTo(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[8].delayTime), cc.rotateTo(this.actionRotates[8].duration, this.actionRotates[8].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[8].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 10) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateTo(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateTo(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateTo(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateTo(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateTo(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateTo(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateTo(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateTo(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[8].delayTime), cc.rotateTo(this.actionRotates[8].duration, this.actionRotates[8].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[8].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[9].delayTime), cc.rotateTo(this.actionRotates[9].duration, this.actionRotates[9].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[9].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            }
        } else {
            if (this.actionRotates.length == 1) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 2) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 3) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 4) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 5) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 6) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateBy(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 7) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateBy(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateBy(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 8) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateBy(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateBy(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateBy(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 9) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateBy(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateBy(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateBy(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[8].delayTime), cc.rotateBy(this.actionRotates[8].duration, this.actionRotates[8].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[8].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            } else if (this.actionRotates.length == 10) {
                this.actionNode.runAction(this.actionID = cc.sequence(
                    cc.delayTime(this.actionRotates[0].delayTime), cc.rotateBy(this.actionRotates[0].duration, this.actionRotates[0].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[0].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[1].delayTime), cc.rotateBy(this.actionRotates[1].duration, this.actionRotates[1].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[1].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[2].delayTime), cc.rotateBy(this.actionRotates[2].duration, this.actionRotates[2].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[2].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[3].delayTime), cc.rotateBy(this.actionRotates[3].duration, this.actionRotates[3].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[3].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[4].delayTime), cc.rotateBy(this.actionRotates[4].duration, this.actionRotates[4].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[4].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[5].delayTime), cc.rotateBy(this.actionRotates[5].duration, this.actionRotates[5].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[5].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[6].delayTime), cc.rotateBy(this.actionRotates[6].duration, this.actionRotates[6].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[6].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[7].delayTime), cc.rotateBy(this.actionRotates[7].duration, this.actionRotates[7].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[7].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[8].delayTime), cc.rotateBy(this.actionRotates[8].duration, this.actionRotates[8].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[8].callback); }.bind(this)),
                    cc.delayTime(this.actionRotates[9].delayTime), cc.rotateBy(this.actionRotates[9].duration, this.actionRotates[9].rotation), cc.callFunc(function() { this.callEventHandler(this.actionRotates[9].callback); }.bind(this)),
                    cc.callFunc(function() { this.action(); this.overCallback(); }.bind(this))));
            }
        }

        this.actionID.setTag(111004);
    },

    overCallback() {
        if (this.currentTime > 1) {
            if (this.allOverCallback) {
                for (let i = 0; i < this.overCallbacks.length; i++) {
                    if (this.overCallbacks[i] != null && this.overCallbacks[i].target != null) {
                        this.overCallbacks[i].emit([this, this.overCallbacks[i].customEventData]);
                    }
                }
            }
        } else {
            for (let i = 0; i < this.overCallbacks.length; i++) {
                if (this.overCallbacks[i] != null && this.overCallbacks[i].target != null) {
                    this.overCallbacks[i].emit([this, this.overCallbacks[i].customEventData]);
                }
            }
        }
    },

    callEventHandler(eventHandler) {
        if (eventHandler && eventHandler.target) {
            eventHandler.emit([this]);
        }
    }
});

 

posted @ 2019-02-13 12:40  wl小胖  阅读(235)  评论(0编辑  收藏  举报