2025-05-29 19:15:32 +08:00
|
|
|
|
const { regClass, property } = Laya
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
|
|
|
|
|
@regClass()
|
|
|
|
|
|
export class AutoRotate extends Laya.Script {
|
2025-05-29 19:15:32 +08:00
|
|
|
|
declare owner: Laya.Image
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
2025-05-29 19:15:32 +08:00
|
|
|
|
@property(Number)
|
|
|
|
|
|
public speed: number = 1
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
2025-05-29 19:15:32 +08:00
|
|
|
|
private begin = 0
|
2025-05-29 19:03:29 +08:00
|
|
|
|
|
2025-05-29 19:15:32 +08:00
|
|
|
|
// 第一次执行update之前执行,只会执行一次
|
|
|
|
|
|
onStart(): void {
|
|
|
|
|
|
Laya.timer.loop(100, this, () => {
|
|
|
|
|
|
this.begin += this.speed
|
|
|
|
|
|
if (this.begin >= 360) {
|
|
|
|
|
|
this.begin = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
this.owner.rotation = this.begin
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|