const { ccclass, property } = cc._decorator;
import EventMgr from "../Common/Module/EventMgr/EventMgr";
import { UICtrl } from "./../Common/UICtrl/UICtrl";

@ccclass
export class nodRestart extends UICtrl {
	onLoad(): void {
		super.onLoad();

		//初始化组件节点
		this.initProperty()
	}

	//重新开始效果
	private sptCircle: cc.Node;
	initProperty() {
		this.sptCircle = this.view["sptCircle"]
	}

	onEnable() {
		this.showRestartBtn();
	}

	onDisable() {
		this.hideRestartBtn();
	}

	//重新开始特效
	showRestartBtn() {
		cc.tween(this.sptCircle)
			.set({ scale: 0.8 * 0.6, opacity: 255 })
			.to(2, { scale: 1.2 * 0.6, opacity: 0 })
			.union()
			.repeatForever()
			.start();
	}

	//关闭重新开始特效
	hideRestartBtn() {
		this.sptCircle.stopAllActions();
		this.sptCircle.scale = 0.8 * 0.6;
		this.sptCircle.opacity = 255;
	}

	//重新开始
	_tap_btnRestart() {
		EventMgr.emit("onRestart");
		this.node.active = false;
	}
}
