Adds the camera to available APIs with retrieving of the worldView
This commit is contained in:
parent
d672a2dead
commit
4356767739
9 changed files with 86 additions and 7 deletions
|
@ -93,6 +93,8 @@ import { MapStore } from "../../Stores/Utils/MapStore";
|
|||
import { SetPlayerDetailsMessage } from "../../Messages/generated/messages_pb";
|
||||
import { followUsersColorStore, followUsersStore } from "../../Stores/FollowStore";
|
||||
import { getColorRgbFromHue } from "../../WebRtc/ColorGenerator";
|
||||
import Camera = Phaser.Cameras.Scene2D.Camera;
|
||||
import type { HasCameraMovedEvent } from "../../Api/Events/HasCameraMovedEvent";
|
||||
|
||||
export interface GameSceneInitInterface {
|
||||
initPosition: PointInterface | null;
|
||||
|
@ -783,6 +785,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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue