// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html



cc.Class({
    extends: cc.Component,

    properties: {
        rotAngle: 0, //旋转角度 
        rotTime: 0,  //旋转时间 
        rotDir: 1,   //旋转方向   1为顺时针 -1为逆时针
        rotType: 0,   //0为沿顺时针或者逆时针一直旋转  1为顺时针和逆时针组合
        haveProp: 0
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function () {

    },


    initProperties: function (configure) {
        this.rotAngle = configure.angle;
        this.rotTime = configure.time;
        this.rotDir = configure.dir;
        this.rotType = configure.type;

        for (let i = 0; i < this.node.children.length; i++) {
            var circle = this.node.getChildByName("c" + i);
            circle.colorType = Math.floor(i / 5);
        }

        this.startActiton();
    },

    startActiton: function () {
        if (this.rotType == 0) {
            var rotateBy = cc.rotateBy(this.rotTime, this.rotAngle * this.rotDir);
            this.node.runAction(cc.repeatForever(rotateBy));
        }
        else if (this.rotType == 1) {
            var rotateBy1 = cc.rotateBy(this.rotTime, this.rotAngle * this.rotDir);
            var rotateBy2 = cc.rotateBy(this.rotTime, -this.rotAngle * this.rotDir);
            this.node.runAction(cc.repeatForever(cc.sequence(rotateBy1, rotateBy2)));
        }
    },

    pauseAction: function () {
        this.node.pauseAllActions();
    },

    resumeAction: function () {
        this.node.resumeAllActions();
    },

    start() {

    },


});
