feat(control) 多角色控制

This commit is contained in:
chicrobot committed 2025-12-30 21:45:25 +08:00
1 parent be5ee91328
commit f86e5f3a79
11 files changed
+431

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
export default class Unit extends Phaser.Physics.Arcade.Sprite {
constructor(scene, x, y, texture) {
super(scene, x, y, texture);
scene.add.existing(this);
scene.physics.add.existing(this);
this.setCollideWorldBounds(true);
}
moveTo(targetX, targetY) {
this.scene.physics.moveToObject(this, {x: targetX, y: targetY}, 200);
}
moveRelative(dirX, dirY, speed = 100) {
this.setVelocity(dirX * speed, dirY * speed);
}
}