Jump to content

Phaser tilemap Image Layer !?


dystop1a
 Share

Recommended Posts

In advance sorry about my lack of reading the documentation! I tried looking at the Phaser Examples and looking around... 

How to link a "Image Layer" from a JSON tilemap generated from Tiled program? 

In the "preload" function I have the asset loaded: 

game.load.image('exit', 'map/exit.png');

 

Then in "create" function I have tried both:

platforms = map.createLayer('exit');

//ERROR - Tilemap.createLayer: Invalid layer ID given: null

platforms = map.addTilesetImage('exit');

//ERROR - Phaser.Tilemap.addTilesetImage: No data found in the JSON matching the tileset name: "exit"

Neither works!? 

map.JSON (i tried moving the exit.png into the route and the image is inside the same folder as the map.JSON file). 

{ "height":130,
 "layers":[ 
        {
         "height":0,
         "image":"exit.png",
         "name":"exit",
         "offsetx":3943,
         "offsety":368,
         "opacity":1,
         "type":"imagelayer",
         "visible":true,
         "width":0,
         "x":0,
         "y":0
        }, 
        

 

Link to comment
Share on other sites

  • 2 weeks later...

I have the same problem, it seems to me that loading the Tiled image layer has not been implemented yet...

There is a custom plugin that can replace phaser's internal Tiled loading functionality, but they haven't implemented the 'Image Layer' either: https://github.com/englercj/phaser-tiled#why-use-this-plugin

So unfortunately you just have to bite the bullet and load the JSON, extract the image information and create the sprites yourself...

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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