export class HomeScene extends Phaser.Scene {
constructor() {
super(`${CST.SCENES.HOME}`);
}
preload(): void {
window.player = new Entity([
new Pos(),
new Move(),
new Attack(),
new Container(this, [
new Sprite(CST.SPRITE_LAYER.BODY, this, 0, 0, CST.SPRITE.RICK)
])
]);
ecs.addEntity(window.player);
const mappy = this.make.tilemap({
key: `${CST.MAP.TESTY}`
});
const tileSet = mappy.addTilesetImage("floor_indoors_tileset");
window.tileSet = tileSet;
mappy.createStaticLayer("ground", tileSet, 0, 0).setOrigin(0);
window.mappy = mappy;
this.cameras.main.startFollow(
window.player.comp.sprite,
false,
1,
1,
-16,
-16
);
}
create(): void {
}
update(time: number, delta: number): void {
}
}
export class InputScene extends Phaser.Scene {
constructor() {
super({ key: `${CST.SCENES.INPUT}`, plugins: ["InputPlugin"] }); //preload is not called if loadplugin is disabled
}
preload(): void {}
create(): void {
//@ts-ignore
this.input.on("pointermove", () => {
//THIESE MOUSEX COORDINATES DO NOT TRANSLATE TO THE SCENE ABOVE
let mouseX = this.input.mousePointer.worldX - window.player.comp.pos.x;
let mouseY = this.input.mousePointer.worldY - window.player.comp.pos.y;
});
}
update() {
}
So my InputScene runs ontop of HomeScene in parallel and I need the mouseX and mouseY to translate their worldX to the HomeScenes input.worldX.
The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with.
I tried destroying the InputScenes camera and setting it to the HomeScenes camera but no luck.