rp_11009/assets/Game/Scripts/FreeSpinAgain.ts
2026-04-01 11:10:33 +08:00

58 lines
1.7 KiB
TypeScript

import { _decorator, Component, Label, Node, tween, Tween, UIOpacity, v3, Vec3 } from 'cc';
import { AudioManager } from '../../Main/Scripts/managers/AudioManager';
const { ccclass, property } = _decorator;
@ccclass('FreeSpinAgain')
export class FreeSpinAgain extends Component {
@property(Node)
grayNode: Node = null;
@property(Node)
mainNode: Node = null;
@property(Label)
freeSpinCount: Label = null;
hasClickBtn: boolean = false;
closeCallBack: () => void = null;
showAgain(cb: () => void) {
this.unscheduleAllCallbacks();
this.closeCallBack = cb;
AudioManager.instance.playBGM('Free_Add_Free');
this.hasClickBtn = false;
let opacity = this.mainNode.getComponent(UIOpacity);
this.hasClickBtn = false;
Tween.stopAllByTarget(this.mainNode);
Tween.stopAllByTarget(opacity);
this.freeSpinCount.string = '5';
opacity.opacity = 0;
tween(opacity)
.to(0.3, { opacity: 255 }, { easing: 'quadIn' })
.start();
this.mainNode.scale = v3(0, 0, 0);
tween(this.mainNode)
.to(0.3, { scale: v3(1, 1, 1) }, { easing: 'quadIn' })
.call(() => {
this.scheduleOnce(() => {
this.onClickGrayBg();
}, 5);
})
.start();
this.grayNode.on(Node.EventType.TOUCH_START, this.onClickGrayBg, this);
}
onClickGrayBg() {
if (this.hasClickBtn) return;
this.hasClickBtn = true;
this.grayNode.off(Node.EventType.TOUCH_START, this.onClickGrayBg, this);
if (this.closeCallBack) this.closeCallBack();
AudioManager.instance.playBGM('Free_Bg_Bgm');
this.node.destroy();
}
}