const { ccclass, property } = cc._decorator;

@ccclass
export default class nodSptStar extends cc.Component {
	@property
	private starNum: number = 0;

	private _timeoutIds: any[];

	onLoad() {
		this._timeoutIds = [];
		this.node.scale = 0;
		this.node.opacity = 0;
	}

	onDestroy(): void {
		this._timeoutIds.forEach(id => {
			clearTimeout(id);
		});
	}

	start() {
		console.log(this.starNum);
		this._timeoutIds.push(setTimeout(() => {
			this.showScale();
		}, this.starNum * 1000))
	}

	//重新开始特效
	showScale() {
		cc.tween(this.node)
			.to(1, { scale: 1, opacity: 255 })
			.delay(0.7)
			.to(1, { scale: 0, opacity: 0 })
			.delay(2)
			.union()
			.repeatForever()
			.start();
	}
}
