merge setPosition and focusOn into setViewport
This commit is contained in:
parent
a1c96b0524
commit
d62b116e5d
9 changed files with 44 additions and 116 deletions
|
@ -254,14 +254,10 @@ export class CameraManager extends Phaser.Events.EventEmitter {
|
|||
);
|
||||
|
||||
this.camera.on("followupdate", () => {
|
||||
this.sendCameraUpdateEvent();
|
||||
this.emit(CameraManagerEvent.CameraUpdate, this.getCameraUpdateEventData());
|
||||
});
|
||||
}
|
||||
|
||||
private sendCameraUpdateEvent(): void {
|
||||
this.emit(CameraManagerEvent.CameraUpdate, this.getCameraUpdateEventData());
|
||||
}
|
||||
|
||||
private getCameraUpdateEventData(): CameraManagerEventCameraUpdateData {
|
||||
return {
|
||||
x: this.camera.worldView.x,
|
||||
|
|
|
@ -1120,20 +1120,23 @@ ${escapedMessage}
|
|||
);
|
||||
|
||||
this.iframeSubscriptionList.push(
|
||||
iframeListener.cameraSetPositionStream.subscribe((cameraSetPositionEvent) => {
|
||||
this.cameraManager.setPosition({ ...cameraSetPositionEvent }, cameraSetPositionEvent.smooth ? 1000 : 0);
|
||||
iframeListener.cameraSetViewportStream.subscribe((cameraSetViewportEvent) => {
|
||||
const duration = cameraSetViewportEvent.smooth ? 1000 : 0;
|
||||
cameraSetViewportEvent.lock
|
||||
? this.cameraManager.enterFocusMode({ ...cameraSetViewportEvent }, undefined, duration)
|
||||
: this.cameraManager.setPosition({ ...cameraSetViewportEvent }, duration);
|
||||
})
|
||||
);
|
||||
|
||||
this.iframeSubscriptionList.push(
|
||||
iframeListener.cameraFocusOnStream.subscribe((cameraFocusOnEvent) => {
|
||||
this.cameraManager.enterFocusMode(
|
||||
{ ...cameraFocusOnEvent },
|
||||
undefined,
|
||||
cameraFocusOnEvent.smooth ? 1000 : 0
|
||||
);
|
||||
})
|
||||
);
|
||||
// this.iframeSubscriptionList.push(
|
||||
// iframeListener.cameraFocusOnStream.subscribe((cameraFocusOnEvent) => {
|
||||
// this.cameraManager.enterFocusMode(
|
||||
// { ...cameraFocusOnEvent },
|
||||
// undefined,
|
||||
// cameraFocusOnEvent.smooth ? 1000 : 0
|
||||
// );
|
||||
// })
|
||||
// );
|
||||
|
||||
this.iframeSubscriptionList.push(
|
||||
iframeListener.cameraFollowPlayerStream.subscribe((cameraFollowPlayerEvent) => {
|
||||
|
@ -1178,8 +1181,6 @@ ${escapedMessage}
|
|||
this.firstCameraUpdateSent = true;
|
||||
}
|
||||
);
|
||||
|
||||
iframeListener.sendCameraUpdated(this.cameras.main);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue