// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

// function test() {
//     let arr = [];
//     let count = -1;
//     for (let i = 0; i < 100; i++) {
//         if(count>1){
//             count=-1
//         }
//         count = count + 1;
//         console.log(i%3);
//     }
// }
// test();


cc.Class({
    extends: cc.Component,

    properties: {
        btn0: cc.Node,
        btn1: cc.Node,
        btn2: cc.Node,
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    //初始播放动画状态为关闭
    onLoad() {
        this.isPlaying = false;
        this.count = -1;
    },
    startPlay() {
        this.isPlaying = true;
    },
    stopPlay() {
        this.isPlaying = false;
    },
    start() {
    },
    update(dt) {//循环播放0 1 2 三种状态
        if (this.isPlaying) {
            if (this.count / 20 % 3 == 0) {//播放20次0
                this.btn0.active = true;
                this.btn1.active = false;
                this.btn2.active = false;
            } else if (this.count / 20 % 3 == 1) {
                this.btn0.active = false;
                this.btn1.active = true;
                this.btn2.active = false;
            } else if (this.count / 20 % 3 == 2) {
                this.btn0.active = false;
                this.btn1.active = false;
                this.btn2.active = true;
            }
            this.count = this.count + 1;
        } else {
            this.btn0.active = false;
            this.btn1.active = false;
            this.btn2.active = true;
        }
    },
});


