Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilemap, when read second time, the prefix added #6212

Closed
wahur666 opened this issue Sep 6, 2022 · 1 comment
Closed

Tilemap, when read second time, the prefix added #6212

wahur666 opened this issue Sep 6, 2022 · 1 comment

Comments

@wahur666
Copy link

wahur666 commented Sep 6, 2022

When loaded a Tiled map editor generated JSON, with the following structure:

kép

Using the following code:

import * as Phaser from "phaser";
import map1 from "./map2.json";

export default class PreloadScene extends Phaser.Scene {
    constructor() {
        super("preload");
    }
    createMap(gameScene) {
        return  gameScene.make.tilemap({key: "map1"});
    }
    preload() {
        this.load.tilemapTiledJSON("map1", map1);
    }
    create() {
        const t1 = window.tileMap = this.createMap(this);
        const t2 = window.tileMap2 = this.createMap(this);
        console.log(t1.objects);
        console.log(t2.objects);
    }
}

The first time the map loaded correctly, with the object layer names, for example: Pads/Pad1

Array(10) [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ]
0: Object { name: "Resources", opacity: 1, type: "objectgroup",  }
1: Object { name: "Pads/Pad1", opacity: 1, type: "objectgroup",  }
2: Object { name: "Pads/Pad2", opacity: 1, type: "objectgroup",  }
3: Object { name: "Pads/Pad3", opacity: 1, type: "objectgroup",  }
4: Object { name: "Nuke", opacity: 1, type: "objectgroup",  }
5: Object { name: "Bases/Base1", opacity: 1, type: "objectgroup",  }
6: Object { name: "Bases/Base2", opacity: 1, type: "objectgroup",  }
7: Object { name: "Water", opacity: 1, type: "objectgroup",  }
8: Object { name: "Terrain", opacity: 1, type: "objectgroup",  }
9: Object { name: "Obstacle", opacity: 1, type: "objectgroup",  }

But when it is loaded for the second time, the result is the following:

Array(10) [ {}, {}, {}, {}, {}, {}, {}, {}, {}, {} ]
0: Object { name: "Resources", opacity: 1, type: "objectgroup",  }
1: Object { name: "Pads/Pads/Pad1", opacity: 1, type: "objectgroup",  }
2: Object { name: "Pads/Pads/Pad2", opacity: 1, type: "objectgroup",  }
3: Object { name: "Pads/Pads/Pad3", opacity: 1, type: "objectgroup",  }
4: Object { name: "Nuke", opacity: 1, type: "objectgroup",  }
5: Object { name: "Bases/Bases/Base1", opacity: 1, type: "objectgroup",  }
6: Object { name: "Bases/Bases/Base2", opacity: 1, type: "objectgroup",  }
7: Object { name: "Water", opacity: 1, type: "objectgroup",  }
8: Object { name: "Terrain", opacity: 1, type: "objectgroup",  }
9: Object { name: "Obstacle", opacity: 1, type: "objectgroup",  }

The name is prefixed once more.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants