rjungemann Posted June 19, 2014 Share Posted June 19, 2014 Good evening all, I am trying to use putTile to generate a tilemap. Unfortunately, whenever, I try and create a tile somewhere other than at x = 1, y = 1, the tile does not appear. I'm using Phaser 2.0.5 and the Ninja tileset, though for this example I've not yet added physics. Note that although I try and create a tile at 1, 1 and one at 1, 2, only one tile appears. I've tried tweaking with the parameters a few different ways to no avail. Thanks in advance!<!DOCTYPE html><html> <head> <title>Tile Example</title> <script src="/javascripts/lib/phaser.js"></script> <script> var game = new Phaser.Game(800, 600, Phaser.AUTO, 'game-container', { preload: preload, create: create, update: update }); function preload(game) { var me = this; me.game.load.image('collision', '/assets/tilemaps/tiles/ninja-tiles32.png'); } function create() { var me = this; me.map = me.game.add.tilemap(); me.map.addTilesetImage('collision', 'collision', 32, 32, 0, 0); me.collisionLayer = me.map.createBlankLayer('collision', 16, 16, 32, 32); me.collisionLayer.visible = true; me.map.putTile(1, 1, 1, 'collision'); me.map.putTile(1, 1, 2, 'collision'); me.collisionLayer.resizeWorld(); } function update() { var me = this; } </script> </head> <body> </body></html> Link to comment Share on other sites More sharing options...
rjungemann Posted June 19, 2014 Author Share Posted June 19, 2014 Anybody? Link to comment Share on other sites More sharing options...
rjungemann Posted June 20, 2014 Author Share Posted June 20, 2014 Is there a way that I can frame my code that would make this more inviting? Is it not possible to have dynamic tilemaps? Link to comment Share on other sites More sharing options...
spencerTL Posted June 20, 2014 Share Posted June 20, 2014 I'm not able to help with your specific problem but I tried the dynamic tilemap route using putTile and it is way too expensive for mobile. 90 calls in a loop would halt the app for 5 seconds or so. I started this thread and had some very useful help:http://www.html5gamedevs.com/topic/7094-slow-tilemap-creation/?hl=%2Bslow+%2Btilemap Link to comment Share on other sites More sharing options...
ragnarok Posted June 20, 2014 Share Posted June 20, 2014 I had some problems when using "createBlankLayer" on the first layer created. However I didn't take the time to investigate further (and that was under 2.04). Using "game.map.create" for the first layer and using "game.map.createBlankLayer" for further layers worked for me. Link to comment Share on other sites More sharing options...
rjungemann Posted June 20, 2014 Author Share Posted June 20, 2014 Thanks, @spencerTL and @ragnarok! What's described in that thread sounds useful. Also good to know about the "createBlankLayer" behavior. My end goal is to design small chunks (like 16x16) of a level in Tiled and then use them kind of like a "rubber stamp" to create a larger level so it doesn't need to be on the fly per se :¬) Link to comment Share on other sites More sharing options...
Recommended Posts