fubeca6 Posted September 7, 2014 Share Posted September 7, 2014 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 More sharing options...
abdul Posted September 7, 2014 Share Posted September 7, 2014 try thisfunction 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 More sharing options...
LZY Posted September 7, 2014 Share Posted September 7, 2014 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 More sharing options...
fubeca6 Posted September 9, 2014 Author Share Posted September 9, 2014 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 More sharing options...
wayfinder Posted September 9, 2014 Share Posted September 9, 2014 Make sure your tileset has the right stuff at the indices it looks for, and Phaser isn't just displaying transparent tiles correctly Link to comment Share on other sites More sharing options...
Recommended Posts