import { _decorator, Component, Node,tween,UIOpacity } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {
    public flag =1;
    start() {

    }

    update(deltaTime: number) {
        
    }
    changeOpacity(){
        if(this.flag==0){
            console.log("flag=0");
            tween(this.node.getComponent(UIOpacity))
            .set({ opacity: 1 }).delay(0).to(0.15, { opacity: 255 }).call(() => {
                this.flag=1;    
            }).start();

        }else{
            console.log("flag=1");
            tween(this.node.getComponent(UIOpacity)).set({ opacity: 1 }).delay(0).to(0.15, { opacity: 255 }).delay(0.4).to(0.15, { opacity: 1 }).call(() => {
                this.node.getComponent(UIOpacity)!.opacity = 1;
                this.flag=0;
            }).start();
        }
    }
    changeActive(event,num){
        for(let i=0;i<this.node.children.length;i++){
            if(i==Number(num)){
                this.node.children[i].active=true;
            }else{
                this.node.children[i].active=false;
            }
        }
    }
}

