Jump to content

Tilemap not rendering


fubeca6
 Share

Recommended Posts

Good evening,

 

I'm having trouble getting my tilemap to render. Instead, it just shows the player sprite on a black background. When I use "layer.debug = true" I can see that the boundaries are correct, it's just not showing the tile images.

 

Here's my relevant code:

function preload() {	// loading my assets	game.load.image('player', 'assets/items/player.png');		game.load.image('tiles', 'assets/tiles/tiles.png');		game.load.tilemap('map', 'assets/maps/level2.json', null, Phaser.Tilemap.TILED_JSON);}function create() {    // configure the map    map = game.add.tilemap('map', 32, 32);    map.addTilesetImage('tiles');    layer = map.createLayer(0);    layer.resizeWorld();       map.setCollision(2);    map.setCollision(4);    map.setCollision(5);    layer.debug = true;}function update() {    game.physics.arcade.collide(this.player, layer);}

Thanks guys

Link to comment
Share on other sites

try this

function create() { // configure the mapmap = game.add.tilemap('map', 32, 32);map.addTilesetImage('tiles','tiles');// first arg is the name of your image file which is in directory with .png extension, and second arg is the name you assigned to that image while loading....layer = map.createLayer(0);layer.resizeWorld();map.setCollision(2);map.setCollision(4);map.setCollision(5);layer.debug = true; }
Link to comment
Share on other sites

and you can merge your map.setCollision() in one:

function create() { // configure the mapmap = game.add.tilemap('map', 32, 32);map.addTilesetImage('tiles','tiles');// first arg is the name of your image file which is in directory with .png extension, and second arg is the name you assigned to that image while loading....layer = map.createLayer(0);layer.resizeWorld();map.setCollision([2, 4, 5]);layer.debug = true; }
Link to comment
Share on other sites

Thank you for the answers, guys, but unfortunately that didn't fix the problem  :(   Even with the "map.addTilesetImage('tiles','tiles');"  line in there, the map is still not showing up. Now, to clarify, the boundaries are there, and I can see them with "layer.debug = true;"  the map is just not showing up

 

Is it possible that there's something wrong with the tile-sheet? I made the map with 'Tiled', which I've used successfully before, but in previous projects I've only used two tiles - a floor, and a wall. In this one I have five tiles.

 

All help is greatly appreciated

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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