AlertManager.ts 902 Bytes
import { ResUtils } from "simba-cc-resutils";
import { AnimationUtils } from "../../utils/AnimationUtils";

class AlertComponent extends cc.Component {
    animate = true;
    start() {
        if (this.animate) {
            // this.node.scale = 0.1;
            // this.node.runAction(cc.sequence(cc.scaleTo(0.3, 1.1), cc.scaleTo(0.2, 0.9), cc.scaleTo(0.2, 1)));
            AnimationUtils.showUIAnim(this.node.getChildByName("mainNode"), { callback: () => { }, maskNodeOpacityValue: 200 }, this.node.getChildByName("BG"))
        }
    }
}

export namespace AlertManager {
    export async function showAlert(parent: cc.Node, node: cc.Node | string, animate = true) {
        if (typeof node === "string") {
            node = await ResUtils.createWithPrefab(node);
        }
        let comp = node.addComponent(AlertComponent);
        comp.animate = animate;
        node.parent = parent;
    }
}