Dr.Linux Posted July 24, 2014 Share Posted July 24, 2014 Can someone tell me why the example isn't working? Thanks in advance, and will provide tile map if needed! From examples.phaser.io!var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload : preload, create: create });function preload() { // Tilemaps are split into two parts: The actual map data (usually stored in a CSV or JSON file) // and the tileset/s used to render the map. // Here we'll load the tilemap data. The first parameter is a unique key for the map data. // The second is a URL to the JSON file the map data is stored in. This is actually optional, you can pass the JSON object as the 3rd // parameter if you already have it loaded (maybe via a 3rd party source or pre-generated). In which case pass 'null' as the URL and // the JSON object as the 3rd parameter. // The final one tells Phaser the foramt of the map data, in this case it's a JSON file exported from the Tiled map editor. // This could be Phaser.Tilemap.CSV too. game.load.tilemap('mario', 'assets/Tilemap.json', null, Phaser.Tilemap.TILED_JSON); // Next we load the tileset. This is just an image, loaded in via the normal way we load images: game.load.image('tiles', 'assets/Tileset.png');}var map;var layer;function create() { // The 'mario' key here is the Loader key given in game.load.tilemap map = game.add.tilemap('mario'); // The first parameter is the tileset name, as specified in the Tiled map editor (and in the tilemap json file) // The second parameter maps this name to the Phaser.Cache key 'tiles' map.addTilesetImage('Tileset', 'tiles'); // Creates a layer from the World1 layer in the map data. // A Layer is effectively like a Phaser.Sprite, so is added to the display list. layer = map.createLayer('Tile Layer 1'); // This resizes the game world to match the layer dimensions layer.resizeWorld();} Link to comment Share on other sites More sharing options...
Kobaltic Posted July 24, 2014 Share Posted July 24, 2014 Double check your names in Tiled. Your tile set is name Tileset here:map.addTilesetImage('Tileset', 'tiles');Is it also named Tileset in Tiled? Your layer is named Tile Layer 1 here:layer = map.createLayer('Tile Layer 1');Is it also named Tile Layer 1 in Tiled? These are the usual suspects. If not post your json file. Link to comment Share on other sites More sharing options...
Dr.Linux Posted July 24, 2014 Author Share Posted July 24, 2014 No Luck, But I did ave to change Tile Set name from 'tileset' to 'Tileset'.Here's the JSON.I tried making it simple by using only one type of tile as a text. The TileSet consists of 3 5x5 blocks.{ "height":10, "layers":[ { "data":[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], "height":10, "name":"Tile Layer 1", "opacity":1, "type":"tilelayer", "visible":true, "width":10, "x":0, "y":0 }], "orientation":"orthogonal", "properties": { }, "tileheight":5, "tilesets":[ { "firstgid":1, "image":"tileset.png", "imageheight":5, "imagewidth":15, "margin":0, "name":"tileset", "properties": { }, "spacing":0, "tileheight":5, "tilewidth":5 }], "tilewidth":5, "version":1, "width":10} Link to comment Share on other sites More sharing options...
Kobaltic Posted July 24, 2014 Share Posted July 24, 2014 The only other thing I see are some capital letters. Make sure your Tilemap.json file starts with a capital 'T' as you have in your filegame.load.tilemap('mario', 'assets/Tilemap.json', null, Phaser.Tilemap.TILED_JSON);If your actual file is a lower case 't' that will cause it not to load. Also in your json file you have both the image is lower case and the name islower case but in your code they have caps. I am not sure if that will throw an issue or not but good practice is to have them the same."image":"tileset.png",game.load.image('tiles', 'assets/Tileset.png'); map.addTilesetImage('Tileset', 'tiles');"name":"tileset", Link to comment Share on other sites More sharing options...
Dr.Linux Posted July 24, 2014 Author Share Posted July 24, 2014 I did change them, but they are still not working... I will attach the tileset. Link to comment Share on other sites More sharing options...
Kobaltic Posted July 25, 2014 Share Posted July 25, 2014 I can't get the tileset from those images. If you can up load it, i will try it out and see what errors get generated. Link to comment Share on other sites More sharing options...
Recommended Posts