rp_11009/assets/Game/Scripts/FreeSpinEnterSpine.ts
TJH 331664be2a
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m17s
取消小游戏加载界面的倒计时音效
2026-05-15 16:05:02 +08:00

112 lines
3.4 KiB
TypeScript

import { _decorator, Component, Label, Node, sp, Tween, tween, UIOpacity, Vec3 } from 'cc';
import { UIManager } from '../../Main/Scripts/managers/UIManager';
import { AudioManager } from '../../Main/Scripts/managers/AudioManager';
const { ccclass, property } = _decorator;
@ccclass('FreeSpinEnterSpine')
export class FreeSpinEnterSpine extends Component {
@property(Node)
mainNode: Node = null;
@property(Node)
envEnterSpineNode: Node = null;
@property(Label)
freeSpinCount: Label = null;
@property(Label)
loadingProgressLabel: Label = null;
@property(Node)
loadingNode: Node = null
@property(Node)
startBtn: Node = null;
hasClickBtn: boolean = false;
showEnterAni(freeSpinCount: number, cb) {
this.mainNode.active = false;
this.envEnterSpineNode.active = false;
this.startBtn.active = false;
this.hasClickBtn = false;
this.loadingNode.active = true;
this.freeSpinCount.string = freeSpinCount.toString();
this.freeSpinCount.node.active = false
Tween.stopAllByTarget(this.loadingNode);
this.startBtn.off(Node.EventType.TOUCH_START);
this.startBtn.on(Node.EventType.TOUCH_START, () => {
this.onClickStartBtn(cb);
});
this.mainNode.active = true;
this.envEnterSpineNode.active = true;
AudioManager.instance.playBGM('Change_Free_Bgm');
// 透明度
let opacity = this.node.getComponent(UIOpacity);
opacity.opacity = 0;
tween(opacity)
.to(0.5, { opacity: 255 }, { easing: 'quadIn' })
.start();
tween(this.mainNode)
.set({ scale: new Vec3(1.1, 1.1, 1.1) })
.to(2, { scale: new Vec3(1, 1, 1) })
.start();
tween(this.envEnterSpineNode)
.set({ scale: new Vec3(1.1, 1.1, 1.1) })
.to(2, { scale: new Vec3(1, 1, 1) })
.start();
tween(this.loadingNode)
.by(1, { angle: -360 })
.repeatForever()
.start();
UIManager.instance.tweenScorelinear(0, 100, 2)
.onUpdate((v: number) => {
this.loadingProgressLabel.string = Math.floor(v).toString();
})
.onComplete(() => {
this.loadingNode.active = false;
this.loadingProgressLabel.string = ''
this.startBtn.active = true;
this.freeSpinCount.node.active = true
this.startBtn.scale = new Vec3(0.1, 0.1, 0.1);
AudioManager.instance.playSFX('Change_Free_Button')
tween(this.startBtn)
.set({ scale: new Vec3(0.1, 0.1, 0.1) })
.to(0.5, { scale: new Vec3(1, 1, 1) })
.call(() => {
this.scheduleOnce(() => {
this.onClickStartBtn(cb);
}, 5)
})
.start();
})
.start();
}
onClickStartBtn(cb: () => void) {
this.unscheduleAllCallbacks();
if (this.hasClickBtn) return;
this.hasClickBtn = true;
AudioManager.instance.stopAllSFX()
// 插入一个放大缩小的动画
tween(this.startBtn)
.to(0.1, { scale: new Vec3(1.1, 1.1, 1.1) })
.to(0.1, { scale: new Vec3(1, 1, 1) })
.call(() => {
cb();
})
.start();
}
}