rp_11001/assets/Game/textures/SCOProject/Scripts/SpinAni.ts
2025-12-18 16:37:45 +08:00

63 lines
1.8 KiB
TypeScript

import { _decorator, CCInteger, Component, tween, Vec3, Node, Animation, Tween, Skeleton, sp } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('SpinAni')
export class SpinAni extends Component {
@property(Node)
private rotateNode: Node = null;
@property(Animation)
private buttonAnimation: Animation = null;
@property(CCInteger)
private idleRotationSpeed: number = 120;
@property(CCInteger)
private runRotationSpeed: number = 540;
@property(CCInteger)
private time: number = 1;
onLoad() {
this.playIdleSpin();
// this.buttonAnimation.play('BtnSpin_idle_animation');
}
private playIdleSpin() {
// Tween.stopAllByTarget(this.rotateNode);
// const duration = 360 / this.idleRotationSpeed * this.time;
// tween(this.rotateNode)
// .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
// .repeatForever()
// .start();
this.rotateNode.getComponent(sp.Skeleton).setAnimation(0, '1', true)
}
public startSpin() {
// Tween.stopAllByTarget(this.rotateNode);
// const duration = 360 / this.runRotationSpeed * this.time;
// tween(this.rotateNode)
// .by(duration, { eulerAngles: new Vec3(0, 0, -360) })
// .repeatForever()
// .start();
// this.buttonAnimation.play('BtnSpin_spin_animation');
// this.buttonAnimation.once(Animation.EventType.FINISHED, () => {
// this.buttonAnimation.play('BtnSpin_idle_animation');
// });
this.rotateNode.getComponent(sp.Skeleton).setAnimation(0, '2', true)
}
public stopSpin() {
this.playIdleSpin();
// this.buttonAnimation.off(Animation.EventType.FINISHED);
// this.buttonAnimation.play('BtnSpin_idle_animation');
}
}