TheScruffyGuy Posted April 22, 2018 Share Posted April 22, 2018 Hi! I am fairly new to Phaser 3 and I have 1 very simple game under my belt (a bulldozer moving rocks around). I am now trying my hand a tile maps so I downloaded Tile and made my map following a few tutorials and now I have my map I have everything set but I keep getting "Uncaught TypeError: Cannot read property 'TILED_JSON' of undefined". I have done alot of reading and I can't seem to find anything helping me with problem. This is all the code I have for right now I am just trying to get my head around tile maps. I have been trying to figure this out for about 2 hours now and I am starting to get a headache, also not asking for anyone to code it for me but pointing me in a direction would be AMAZING! function preload () { this.load.tilemap('store1', 'assets/images/untitled.json', null, Phaser.Tilemap.TILED_JSON); this.load.image('tileS','assets/images/spriteSbuild.png'); } function create () { this.map = this.add.tilemap('store1', 32, 32, 64, 32 ); this.map.addTilesetImage('tileS','assets/images/spriteSbuild.png'); this.map.createLayer('Tile Layer 1').resizeWorld(); } Link to comment Share on other sites More sharing options...
theNeedle Posted April 22, 2018 Share Posted April 22, 2018 @TheScruffyGuy I had never worked with Tilemaps but I think there should be Phaser.Tilemaps.TILED_JSON in 1st line of preload function. I found it here. Link to comment Share on other sites More sharing options...
TheScruffyGuy Posted April 22, 2018 Author Share Posted April 22, 2018 I had it but I didn't put a "s" on the end of Tilemaps... not it's telling me, "this.load.tilemap" is not a function.. more troubleshooting Link to comment Share on other sites More sharing options...
B3L7 Posted April 24, 2018 Share Posted April 24, 2018 From what I can tell you have a couple things off: function preload () { this.load.tilemapTiledJSON('store1', 'assets/images/untitled.json'); this.load.spritesheet('tileS', 'assets/images/spriteSbuild.png', { frameWidth: 16, frameHeight: 16 }); } function create () { this.map = this.make.tilemap({ key: 'store1' }); let tileset = this.map.addTilesetImage('tileS','assets/images/spriteSbuild.png'); this.map.createStaticLayer('Tile Layer 1', tileset).resizeWorld(); } Not sure what your tile size is (frameWidth). Hope that helps. Link to comment Share on other sites More sharing options...
snowbillr Posted April 24, 2018 Share Posted April 24, 2018 This might be a relevant example for you - https://labs.phaser.io/edit.html?src=src\game objects\tilemap\static\tiled-json-map.js samme 1 Link to comment Share on other sites More sharing options...
MagP Posted May 8, 2018 Share Posted May 8, 2018 Hi everyone, Silly question, the line 'this.load.image('tiles', 'assets/tilemaps/tiles/cybernoid.png');' on the example snowbillr put, does it mean the map as a png you have created, or the spritesheet? as I tried using the spritesheet and I can´t make it work anyhow. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts