can manage position and width/height of a popUp using a square in Tiled
This commit is contained in:
parent
5e4940dba6
commit
8d0411e8a3
@ -391,7 +391,6 @@ export class GameScene extends ResizableScene implements CenterListener {
|
||||
this.popUpWidth = Math.floor(object.width);
|
||||
this.popUpHeight = Math.floor(object.height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -757,17 +756,21 @@ 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 id="container" <div class="nes-container with-title is-centered"
|
||||
>
|
||||
${escapedMessage}
|
||||
</div> `;
|
||||
</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(this.popUpX + this.popUpWidth/2 ,
|
||||
this.popUpY + this.popUpHeight/2).createFromHTML(html);
|
||||
|
||||
let container : HTMLDivElement = domElement.getChildByID("container") as HTMLDivElement;
|
||||
container.style.width = this.popUpWidth + "px";
|
||||
container.style.height = this.popUpHeight + "px";
|
||||
domElement.scale = 0;
|
||||
domElement.setClassName('popUpElement');
|
||||
|
||||
|
@ -75,15 +75,15 @@
|
||||
"name":"floorLayer",
|
||||
"objects":[
|
||||
{
|
||||
"height":195.65688359926,
|
||||
"height":162.662798398032,
|
||||
"id":1,
|
||||
"name":"myPopup",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":315.393884378036,
|
||||
"x":-0.29745661104063,
|
||||
"y":-0.433231160918936
|
||||
"width":16.3413326605909,
|
||||
"x":275.392367109435,
|
||||
"y":141.649957637921
|
||||
}],
|
||||
"opacity":1,
|
||||
"type":"objectgroup",
|
||||
|
Loading…
Reference in New Issue
Block a user