terebentina Posted May 8, 2014 Share Posted May 8, 2014 I am trying to swap 2 tiles (actually I just need to move a tile up/down/left/right, in place of an empty tile).I tried using tilemap.swap(tileA, tileB) but that only copies tileA over tileB, not the other way around too.The "swap tiles" example says it's supposed to really swap (copy A over B and B over A) but this doesn't happen there either. Is there any method that I am missing that can do this? And, since I am trying to move a tile over an empty place, is there a way to tween this move? Any help is greatly appreciated.Dan Link to comment Share on other sites More sharing options...
jpdev Posted May 8, 2014 Share Posted May 8, 2014 For dealing with manipulating single tiles (or in your case two) I love this example: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=paint+tiles.js&t=paint%20tiles Just get the index for each of the tiles you want to swap, and then switch those indexes. (Following the "paint" code in the example) Link to comment Share on other sites More sharing options...
terebentina Posted May 9, 2014 Author Share Posted May 9, 2014 Thanks, The example is using map.putTile() but I do see putTile() is basically setting the index of the tile. I'll give it a try. I am thinking of first tweening the coordinates of the initial tile to move over the destination tile and then set the index on tween complete. I'll let you know how it goes. Link to comment Share on other sites More sharing options...
Recommended Posts