101 lines
3.1 KiB
TypeScript
101 lines
3.1 KiB
TypeScript
import { _decorator, Component, Label, Node, sp, Tween, tween, 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;
|
|
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);
|
|
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.playSFX('Click_Small_Game_Start');
|
|
// 插入一个放大缩小的动画
|
|
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();
|
|
}
|
|
}
|
|
|