Set Position of the popUp with pos of an object in floorLayer object group
This commit is contained in:
parent
4545de8af1
commit
f7f8be24bc
@ -169,6 +169,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
private popUpElements : Map<number, DOMElement> = new Map<number, Phaser.GameObjects.DOMElement>();
|
||||||
private popUpX! : number;
|
private popUpX! : number;
|
||||||
private popUpY! : number;
|
private popUpY! : number;
|
||||||
|
private popUpWidth! : number;
|
||||||
|
private popUpHeight! : number;
|
||||||
|
|
||||||
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
|
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
|
||||||
super({
|
super({
|
||||||
@ -386,6 +388,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
if (object.name === 'myPopup') {
|
if (object.name === 'myPopup') {
|
||||||
this.popUpX = Math.floor(object.x);
|
this.popUpX = Math.floor(object.x);
|
||||||
this.popUpY = Math.floor(object.y);
|
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 {
|
private listenToIframeEvents(): void {
|
||||||
iframeListener.openPopupStream.subscribe((openPopupEvent) => {
|
iframeListener.openPopupStream.subscribe((openPopupEvent) => {
|
||||||
const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message);
|
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}
|
${escapedMessage}
|
||||||
</div>`;
|
</div> `;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
for (const button of openPopupEvent.buttons) {
|
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>`;
|
html += `<button type="button" class="nes-btn is-${HtmlUtils.escapeHtml(button.className ?? '')}" id="popup-${openPopupEvent.popupId}-${id}">${HtmlUtils.escapeHtml(button.label)}</button>`;
|
||||||
id++;
|
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.scale = 0;
|
||||||
domElement.setClassName('popUpElement');
|
domElement.setClassName('popUpElement');
|
||||||
|
|
||||||
|
@ -75,15 +75,15 @@
|
|||||||
"name":"floorLayer",
|
"name":"floorLayer",
|
||||||
"objects":[
|
"objects":[
|
||||||
{
|
{
|
||||||
"height":120.377012261239,
|
"height":195.65688359926,
|
||||||
"id":1,
|
"id":1,
|
||||||
"name":"myPopup",
|
"name":"myPopup",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":162.815914588373,
|
"width":315.393884378036,
|
||||||
"x":76.1933509951528,
|
"x":-0.29745661104063,
|
||||||
"y":167.886910114979
|
"y":-0.433231160918936
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
|
Loading…
Reference in New Issue
Block a user