Jump to content

TILED_JSON headache!


TheScruffyGuy
 Share

Recommended Posts

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

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

  • 2 weeks later...

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

 Share

  • Recently Browsing   0 members

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