mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-29 22:41:29 +08:00
feat(item) 优化移动及添加测试场景
This commit is contained in:
1 parent
2f7210f47e
commit
b9a5180293
15 files changed
+1428
-62
No files matched your search
+10
-11
@@ -1,6 +1,6 @@
|
||||
// ui/VirtualJoystick.js
|
||||
export class VirtualJoystick {
|
||||
constructor(scene) {
|
||||
constructor(scene, enabled = true) {
|
||||
this.scene = scene;
|
||||
this.isActive = false;
|
||||
this.base = null;
|
||||
@@ -9,16 +9,14 @@ export class VirtualJoystick {
|
||||
this.centerX = 0;
|
||||
this.centerY = 0;
|
||||
this.radius = 50;
|
||||
this.enabled = enabled;
|
||||
|
||||
// 仅在触屏设备显示
|
||||
// if ('ontouchstart' in window) {
|
||||
// this.create();
|
||||
// this.bindEvents();
|
||||
// }
|
||||
|
||||
// 在所有设备上都显示摇杆
|
||||
this.create();
|
||||
this.bindEvents();
|
||||
// 仅在启用时创建摇杆
|
||||
if (this.enabled) {
|
||||
// 在所有设备上都显示摇杆
|
||||
this.create();
|
||||
this.bindEvents();
|
||||
}
|
||||
}
|
||||
|
||||
create() {
|
||||
@@ -84,7 +82,8 @@ export class VirtualJoystick {
|
||||
* 更新方法,用于在游戏循环中持续发送移动指令
|
||||
*/
|
||||
update() {
|
||||
if (this.isActive && this.pointer) {
|
||||
// 仅在启用时更新
|
||||
if (this.enabled && this.isActive && this.pointer) {
|
||||
const dx = this.pointer.x - this.centerX;
|
||||
const dy = this.pointer.y - this.centerY;
|
||||
|
||||
|
||||
Reference in new issue
Block a user