// 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

import pg from "./pg_OP05";
cc.Class({
    extends: cc.Component,

    properties: {
        // 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.p0 = pg.view.find(this, "p0");
        this.p1 = pg.view.find(this, "p1");
        this.p2 = pg.view.find(this, "p2");
        this.count = 0;
    },

    start() {

    },

    update(dt) {
        if (!this.p0) return;
        this.count++;
        let m = Math.floor(this.count / 20) % 4;
        this[`p0`].scaleX = m == 1 ? 1.3 : 1.0;
        this[`p0`].scaleY = m == 1 ? 1.3 : 1.0;
        this[`p1`].scaleX = m == 2 ? 1.3 : 1.0;
        this[`p1`].scaleY = m == 2 ? 1.3 : 1.0;
        this[`p2`].scaleX = m == 3 ? 1.3 : 1.0;
        this[`p2`].scaleY = m == 3 ? 1.3 : 1.0;
    },
});
