rp_11001/assets/Game/scripts/game/FreeSpinAdd.ts
TJH c182f6656c
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m54s
添加新动效
2025-12-20 14:53:19 +08:00

75 lines
2.8 KiB
TypeScript

import { _decorator, Button, Component, Label, Node, Prefab, sp, Sprite, Tween, tween, UIOpacity, v3, Vec3 } from 'cc';
import { NodePoolManager } from '../../../Loading/scripts/manager/NodePoolManager';
import { AudioManager } from 'db://assets/Loading/scripts/manager/AudioManager';
const { ccclass, property } = _decorator;
@ccclass('FreeSpinAdd')
export class FreeSpinAdd extends Component {
@property(Prefab)
freeSpinAddPre: Prefab = null;
freeSpinAddUI: Node = null;
freeSpinEnterSpine: sp.Skeleton | null = null;
freeSpinEnterTitleSp: Sprite | null = null;
freeCountLabel: Label | null = null;
freeCount: number = 0;
closeCallBack: (() => void) | null = null;
show(freeCount: number, closeCallBack: (() => void) | null = null) {
AudioManager.instance.playSFX('Free_Trigger_Free_Sound');
this.freeSpinAddUI = NodePoolManager.instance.getNodeFromPoolStatic('freeSpinAdd', this.freeSpinAddPre);
this.freeSpinEnterSpine = this.freeSpinAddUI.getChildByName('spine').getComponent(sp.Skeleton);
let numNode = this.freeSpinEnterSpine.node.getChildByName('NumNode');
this.freeCountLabel = numNode.getChildByName('Label').getComponent(Label);
let titleNode = this.freeSpinEnterSpine.node.getChildByName('TitleNode');
this.freeSpinEnterTitleSp = titleNode.getChildByName('SpriteFREESPINWON').getComponent(Sprite);
this.freeCount = freeCount;
this.freeCountLabel.string = `${freeCount}`;
this.node.addChild(this.freeSpinAddUI);
this.playAnimation();
this.closeCallBack = closeCallBack;
}
playAnimation() {
this.freeSpinEnterSpine.clearTracks();
this.freeSpinEnterSpine.setAnimation(0, 'animation', true);
this.freeSpinEnterSpine.node.setScale(0, 0, 0)
this.freeSpinEnterSpine.node.getComponent(UIOpacity).opacity = 0
tween(this.freeSpinEnterSpine.node)
.to(0.5, { scale: new Vec3(1, 1, 1) })
.call(() => {
this.scheduleOnce(() => {
this.onClose();
}, 5)
})
.start()
tween(this.freeSpinEnterSpine.node.getComponent(UIOpacity))
.to(0.5, { opacity: 255 })
.start()
}
// 加入回调
onClose() {
this.unscheduleAllCallbacks();
tween(this.freeSpinEnterSpine.node)
.to(0.5, { scale: new Vec3(0, 0, 0) })
.call(() => {
this.freeSpinAddUI.removeFromParent();
NodePoolManager.instance.putNodeToPool('freeSpinAdd', this.freeSpinAddUI);
this.closeCallBack && this.closeCallBack();
})
.start()
tween(this.freeSpinEnterSpine.node.getComponent(UIOpacity))
.to(0.5, { opacity: 0 })
.start()
}
}