I encountered two persistent errors that I have been unable to resolve. While the application runs smoothly in Vite, it fails to transpile due to the mentioned errors outlined below:
import Phaser from "phaser";
export default class GameScene extends Phaser.Scene {
// Game elements
player!: Phaser.Physics.Arcade.Sprite;
stars!: Phaser.Physics.Arcade.Group;
bombs!: Phaser.Physics.Arcade.Group;
platforms!: Phaser.Physics.Arcade.StaticGroup;
// rest of the code remains the same...
In this segment of the code:
this.physics.add.overlap(
this.player,
this.stars,
this.collectStar,
undefined,
this
);
this.physics.add.collider(
this.player,
this.bombs,
this.hitBomb,
undefined,
this
);
The methods this.collectStar and this.hitBomb are throwing errors. The specific errors reported are:
Error: Argument of type '(player: GameObject, star: GameObject) => void' is not assignable to parameter of type 'ArcadePhysicsCallback'. Types of parameters 'player' and 'object1' are incompatible. Type 'GameObjectWithBody | Tile' is not assignable to type 'GameObject'. Type 'Tile' is missing essential properties.ts(2345) (method) GameScene.collectStar(player: Phaser.GameObjects.GameObject, star: Phaser.GameObjects.GameObject): void
and
Error: Argument of type '(player: GameObject, bomb: GameObject) => void' is not assignable to parameter of type 'ArcadePhysicsCallback'. Types of parameters 'player' and 'object1' are incompatible. Type 'GameObjectWithBody | Tile' is not compatible with 'GameObject'. Type 'Tile' lacks certain mandatory properties.ts(2345) (method) GameScene.hitBomb(player: Phaser.GameObjects.GameObject, bomb: Phaser.GameObjects.GameObject): void
Is there any guidance on rectifying these issues? Any insights or suggestions would be greatly appreciated.
PS. The full source code can be accessed via: https://github.com/michaelkolesidis/chompy-o-croc
To proceed with deployment, I have temporarily resolved the errors by inserting // @ts-ignore before each occurrence on GitHub (lines 162 and 170).