Get position of an object in Tile to set popUp Position
This commit is contained in:
parent
70898a2f28
commit
d29e0819f4
@ -167,6 +167,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
private playerName!: string;
|
private playerName!: string;
|
||||||
private characterLayers!: string[];
|
private characterLayers!: string[];
|
||||||
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 popUpY! : number;
|
||||||
|
|
||||||
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
|
constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) {
|
||||||
super({
|
super({
|
||||||
@ -379,6 +381,13 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
}
|
}
|
||||||
if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
|
if (layer.type === 'objectgroup' && layer.name === 'floorLayer') {
|
||||||
depth = 10000;
|
depth = 10000;
|
||||||
|
for (const object of layer.objects) {
|
||||||
|
if (object.name === 'myPopup') {
|
||||||
|
this.popUpX = Math.floor(object.x);
|
||||||
|
this.popUpY = Math.floor(object.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (depth === -2) {
|
if (depth === -2) {
|
||||||
@ -734,6 +743,7 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
if (newValue === undefined || newValue === false || newValue === '') {
|
if (newValue === undefined || newValue === false || newValue === '') {
|
||||||
iframeListener.sendLeaveEvent(oldValue as string);
|
iframeListener.sendLeaveEvent(oldValue as string);
|
||||||
} else {
|
} else {
|
||||||
|
console.log("je passe dans zone");
|
||||||
iframeListener.sendEnterEvent(newValue as string);
|
iframeListener.sendEnterEvent(newValue as string);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -743,13 +753,11 @@ 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>`;
|
||||||
|
const domElement = this.add.dom(this.popUpX, this.popUpY).createFromHTML(html);
|
||||||
const domElement = this.add.dom(150, 150).createFromHTML(html);
|
domElement.scale = 1;
|
||||||
domElement.scale = 0;
|
|
||||||
domElement.setClassName('popUpElement');
|
domElement.setClassName('popUpElement');
|
||||||
this.tweens.add({
|
this.tweens.add({
|
||||||
targets : domElement ,
|
targets : domElement ,
|
||||||
|
@ -82,8 +82,8 @@
|
|||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":162.815914588373,
|
"width":162.815914588373,
|
||||||
"x":77.4042872633247,
|
"x":76.1933509951528,
|
||||||
"y":61.1226958044874
|
"y":167.886910114979
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
@ -101,7 +101,7 @@
|
|||||||
"value":"script.js"
|
"value":"script.js"
|
||||||
}],
|
}],
|
||||||
"renderorder":"right-down",
|
"renderorder":"right-down",
|
||||||
"tiledversion":"1.3.3",
|
"tiledversion":"1.4.3",
|
||||||
"tileheight":32,
|
"tileheight":32,
|
||||||
"tilesets":[
|
"tilesets":[
|
||||||
{
|
{
|
||||||
@ -119,6 +119,6 @@
|
|||||||
}],
|
}],
|
||||||
"tilewidth":32,
|
"tilewidth":32,
|
||||||
"type":"map",
|
"type":"map",
|
||||||
"version":1.2,
|
"version":1.4,
|
||||||
"width":10
|
"width":10
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user