mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-29 19:41:29 +08:00
16 lines
452 B
JavaScript
16 lines
452 B
JavaScript
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);
|
|
}
|
|
} |