Adds the camera to available APIs with retrieving of the worldView

This commit is contained in:
Benedicte Quimbert 2021-11-23 16:51:39 +01:00
parent 99dfd77600
commit 5b6a8ca4d7
9 changed files with 86 additions and 7 deletions

View file

@ -30,6 +30,7 @@ export class EmbeddedWebsiteManager {
height: rect["height"],
},
origin: website.origin,
scale: website.scale,
};
});
@ -144,9 +145,9 @@ export class EmbeddedWebsiteManager {
name,
url,
/*x,
y,
width,
height,*/
y,
width,
height,*/
allow,
allowApi,
visible,

View file

@ -89,6 +89,8 @@ import { get } from "svelte/store";
import { contactPageStore } from "../../Stores/MenuStore";
import { GameMapProperties } from "./GameMapProperties";
import SpriteSheetFile = Phaser.Loader.FileTypes.SpriteSheetFile;
import Camera = Phaser.Cameras.Scene2D.Camera;
import type { HasCameraMovedEvent } from "../../Api/Events/HasCameraMovedEvent";
export interface GameSceneInitInterface {
initPosition: PointInterface | null;
@ -750,6 +752,17 @@ export class GameScene extends DirtyScene {
this.gameMap.setPosition(event.x, event.y);
});
//listen event to share the actual worldView when the camera is updated
this.cameras.main.on("followupdate", (camera: Camera) => {
const worldView: HasCameraMovedEvent = {
x: camera.worldView.x,
y: camera.worldView.y,
width: camera.worldView.width,
height: camera.worldView.height,
};
iframeListener.hasCameraMoved(worldView);
});
// Set up variables manager
this.sharedVariablesManager = new SharedVariablesManager(
this.connection,