自动旋转问题

This commit is contained in:
2025-06-17 20:02:13 +08:00
parent 2ff5cc77b5
commit eb36a104a3
5 changed files with 18 additions and 17 deletions

View File

@@ -101,7 +101,7 @@
{
"_$type": "b4f67ca3-86fe-409d-a439-63a715243fb7",
"scriptPath": "../src/views/common/AutoRotate.ts",
"speed": 1
"speed": 0.2
}
]
},

View File

@@ -3,8 +3,8 @@
"_$id": "fxmpuoug",
"_$type": "Box",
"name": "GameDone_DC_H",
"width": 1920,
"height": 1080,
"width": 1080,
"height": 1920,
"_mouseState": 2,
"drawCallOptimize": true,
"left": 0,
@@ -64,8 +64,8 @@
"_$id": "qsfvdnby",
"_$type": "Image",
"name": "bg_done",
"width": 1920,
"height": 1080,
"width": 1080,
"height": 1920,
"left": 0,
"right": 0,
"top": 0,
@@ -77,6 +77,8 @@
"_$id": "ksvwr0iw",
"_$type": "Box",
"name": "center",
"x": -420,
"y": 420,
"width": 1920,
"height": 1080,
"centerX": 0,
@@ -115,7 +117,7 @@
{
"_$type": "b4f67ca3-86fe-409d-a439-63a715243fb7",
"scriptPath": "../src/views/common/AutoRotate.ts",
"speed": 1
"speed": 0.2
}
]
},

View File

@@ -101,7 +101,7 @@
{
"_$type": "b4f67ca3-86fe-409d-a439-63a715243fb7",
"scriptPath": "../src/views/common/AutoRotate.ts",
"speed": 1
"speed": 0.2
}
]
},

View File

@@ -3,8 +3,8 @@
"_$id": "mydj8ynl",
"_$type": "Box",
"name": "GameDone_Normal_H",
"width": 1920,
"height": 1080,
"width": 1080,
"height": 1920,
"_mouseState": 2,
"drawCallOptimize": true,
"left": 0,
@@ -64,8 +64,8 @@
"_$id": "cofbpy83",
"_$type": "Image",
"name": "bg_done",
"width": 1920,
"height": 1080,
"width": 1080,
"height": 1920,
"left": 0,
"right": 0,
"top": 0,
@@ -77,6 +77,8 @@
"_$id": "bhko8e4w",
"_$type": "Box",
"name": "center",
"x": -420,
"y": 420,
"width": 1920,
"height": 1080,
"centerX": 0,
@@ -115,7 +117,7 @@
{
"_$type": "b4f67ca3-86fe-409d-a439-63a715243fb7",
"scriptPath": "../src/views/common/AutoRotate.ts",
"speed": 1
"speed": 0.2
}
]
},

View File

@@ -5,18 +5,15 @@ export class AutoRotate extends Laya.Script {
declare owner: Laya.Image
@property(Number)
public speed: number = 1
public speed: number = 0.2
private begin = 0
// 第一次执行update之前执行只会执行一次
onStart(): void {
Laya.timer.loop(100, this, () => {
onLateUpdate(): void {
this.begin += this.speed
if (this.begin >= 360) {
this.begin = 0
}
this.owner.rotation = this.begin
})
}
}