mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-29 20:41:29 +08:00
feat(control) 多角色控制
This commit is contained in:
1 parent
be5ee91328
commit
f86e5f3a79
11 files changed
+431
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user