Jump to content

Bring to top phaser layer data item


Recommended Posts

I want to use method BringToTop for layer data item. But it doesnt work for me.

I have some layers, and i want to hide my character behind some sprites.

I need something like that: 


But i have got it:

Here is my code:

this.parent.Location.location = this.parent.game.add.tilemap('map');
if (!this.parent.Location.props.images) {
    console.error('Images are empty or undefined read readme.md for information');
    return false;
_.each(this.parent.Location.props.images, (layer, index) => {
    this.parent.Location.location.addTilesetImage(layer.name, layer.name);
    this.parent.Location[layer.layer] = this.parent.Location.location.createLayer(layer.layer);
    if (_.size(layer.bringToTop)) {
        this.bringToTop(index, layer.bringToTop); // 0, [6,7]
bringToTop(index, bringToTopArray) {
    let gid = this.parent.Location.location.tilesets[index].firstgid;
    _.each(bringToTopArray, (itemBring) => {
        _.each(this.parent.Location.location.layers[index].data, (layerData) => {
            _.each(layerData, (layerDataItem) => {
                if ((itemBring + gid) === layerDataItem.index) {
                    let timeAfterLoad = this.parent.game.time.events.add(0, () => {

If you know another ways how i can resolve that problem, let me know please.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...