// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import Common5 from "../Platform/th/Common5";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Node)
    flower1: cc.Node = null;
    
    @property(cc.Node)
    flower2: cc.Node = null;
    
    @property(cc.Node)
    flower3: cc.Node = null;
    
    @property(cc.Node)
    flower4: cc.Node = null;
    
    @property(cc.Node)
    flower5: cc.Node = null;
    
    @property(cc.Node)
    flower6: cc.Node = null;
    
    @property(cc.Node)
    flower7: cc.Node = null;
    
    @property(cc.Node)
    flower8: cc.Node = null;
    
    @property(cc.Node)
    flower9: cc.Node = null;
    
    @property(cc.Node)
    flower10: cc.Node = null;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
        let x = 0;
        let y = 0;
        x = 50;
        y = 42;
        this.showAni(this.flower1,x,y);
        
        x = -11;
        y = 87;
        this.showAni(this.flower2,x,y);
        
        x = -44;
        y = 56;
        this.showAni(this.flower3,x,y);

        x = -86;
        y = 28;
        this.showAni(this.flower4,x,y);
        
        x = -93;
        y = -11;
        this.showAni(this.flower5,x,y);
        
        x = -64;
        y = -54;
        this.showAni(this.flower6,x,y);

        x = -28;
        y = -74;
        this.showAni(this.flower7,x,y);

        x = -13;
        y = -80;
        this.showAni(this.flower8,x,y);
        
        x = 51;
        y = -64;
        this.showAni(this.flower9,x,y);
        
        x = 67;
        y = -13;
        this.showAni(this.flower10,x,y);

        this.scheduleOnce(()=>{
            this.node.removeFromParent();
        },0.7)
    }

    showAni(node,posX,posY){
        cc.tween(node).to(0.7,{x:posX*1.5,y:posY*1.5,opacity:0,scale:Common5.getRandomNum(0.3,0.7)}).delay(0.2).start();
    }
    // update (dt) {}
}