Closed songyukino1 closed 1 year ago
I am writing a chess in TypeScript. According to the documentation example, I wrote the following code, but it is giving me an error.
import { MoveTo } from 'phaser3-rex-plugins/plugins/board-components'; import Level from "../scenes/Level"; import MyBoard from "./Board"; import Box from "./Box"; export default class Player extends Phaser.GameObjects.Sprite { constructor(scene: Level, board: MyBoard) { super(scene, 0, 0, "tilesheet", 5) scene.add.existing(this) this.moveTo = scene.rexBoard.add.moveTo(this, { occupiedTest: true }) .on('occupy', (box: Box, player: Player) => { const direction = board.directionBetween(player, box); box.moveTo.moveToward(direction); }) } moveTo: MoveTo wander() { if (this.moveTo.isRunning) { return; } this.moveTo .once('complete', () => { this.wander(); }) .moveToRandomNeighbor(); } }
console.log(box)
i found that the method does exist
Alright, it seems like I've figured it out. I need to add an "occupiedTest" property to the box.
I am writing a chess in TypeScript. According to the documentation example, I wrote the following code, but it is giving me an error.
i found that the method does exist