dystop1a

Phaser tilemap Image Layer !?

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
        }, 
        

 

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
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.

Guest
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.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.