Jump to content

Help With Tilemaps And Tilesets


StuffBySpencer
 Share

Recommended Posts

I need help with creating tilemaps.

 

I use tiled to create the maps, however it seems that tiled is counting my tileset image starting at 1, while phaser counts tilesets starting from 0.

 

Because of this, whenever I make a tilemap, the blocks are out of order, and the map looks all screwey.

Please help, I have attached an image to better explain this:

 

KFo1ME2.png

Link to comment
Share on other sites

This gives me a nice short snappy jump. Jump velocity is -500:

    game.physics.arcade.gravity.y = 300;    player = game.add.sprite(32, 320, 'dude');    game.physics.enable(player, Phaser.Physics.ARCADE);    player.body.collideWorldBounds = true;    player.body.gravity.y = 1000;    player.body.maxVelocity.y = 500;    player.body.setSize(20, 32, 5, 16);
Link to comment
Share on other sites

The first problem is what happens when you don't add the correct parameters into the map.addTilesetImage().

 

The first should be the name of the tileset you named in your script, the second should be the name of the tileset that your map editor named it. To find this out, open your json map file, and look at the tileset-name.

Link to comment
Share on other sites

Hi spancer

 

i have this:

 

"tilesets":[
        {
         "firstgid":1,
         "image":"tmw_desert_spacing.png",
         "imageheight":1000,
         "imagewidth":1000,
         "margin":0,
         "name":"terrain",
         "properties":
            {
 
            },
         "spacing":0,
         "tileheight":32,
         "tilewidth":32
        }],
 
in the scripts:
 
tileset = map.addTilesetImage('tiles','terrain');
 
and the error:
 
Phaser.Cache.getImage: Invalid key: "terrain" phaser.min.js:13
  1. Uncaught TypeError: Cannot read property 'height' of undefined
Link to comment
Share on other sites

@ema9: You probably need to flip the arguments:

 

map.addTilesetImage('terrain', 'tiles');

 

The first argument is the name of the tileset in Tiled. The second argument is the cache key of the tileset image in Phaser. (Thus, you need to preload the tileset image with the key 'tiles'.)

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.

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

  • Recently Browsing   0 members

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