Set Position of the popUp with pos of an object in floorLayer object group

This commit is contained in:
DESKTOP-FMM8UI0\CLV 2021-03-10 08:57:49 +01:00
parent 4545de8af1
commit f7f8be24bc
2 changed files with 12 additions and 7 deletions

View File

@ -169,6 +169,8 @@ export class GameScene extends ResizableScene implements CenterListener {
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
private popUpX! : number;
private popUpY! : number;
private popUpWidth! : number;
private popUpHeight! : number;
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
super({
@ -386,6 +388,8 @@ export class GameScene extends ResizableScene implements CenterListener {
if (object.name === 'myPopup') {
this.popUpX = Math.floor(object.x);
this.popUpY = Math.floor(object.y);
this.popUpWidth = Math.floor(object.width);
this.popUpHeight = Math.floor(object.height);
}
}
@ -753,16 +757,17 @@ export class GameScene extends ResizableScene implements CenterListener {
private listenToIframeEvents(): void {
iframeListener.openPopupStream.subscribe((openPopupEvent) => {
const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message);
let html = `<div class="nes-container with-title is-centered">
let html = ` <div class="nes-container with-title is-centered"
>
${escapedMessage}
</div>`;
</div> `;
let id = 0;
for (const button of openPopupEvent.buttons) {
html += `<button type="button" class="nes-btn is-${HtmlUtils.escapeHtml(button.className ?? '')}" id="popup-${openPopupEvent.popupId}-${id}">${HtmlUtils.escapeHtml(button.label)}</button>`;
id++;
}
const domElement = this.add.dom(this.popUpX, this.popUpY,).createFromHTML(html);
const domElement = this.add.dom(150, 150).createFromHTML(html);
domElement.scale = 0;
domElement.setClassName('popUpElement');

View File

@ -75,15 +75,15 @@
"name":"floorLayer",
"objects":[
{
"height":120.377012261239,
"height":195.65688359926,
"id":1,
"name":"myPopup",
"rotation":0,
"type":"",
"visible":true,
"width":162.815914588373,
"x":76.1933509951528,
"y":167.886910114979
"width":315.393884378036,
"x":-0.29745661104063,
"y":-0.433231160918936
}],
"opacity":1,
"type":"objectgroup",