Jump to content

Trouble with putTile


rjungemann
 Share

Recommended Posts

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

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

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

 Share

  • Recently Browsing   0 members

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