Jump to content

Tilemap Highlighting


Recommended Posts

Hi all,


One of the requirements of my game is to "highlight" potential moves the player is able to make.  Ideally this would be simple, such as tinting the tile green.  However, I can't see any way to tint a tile.


One thing I did try is creating a unique tilemap layer over the one I'm trying to highlight, and do something like this:

this.visibilityLayer = this.map.createLayer('visibility');var tiles = this.visibilityLayer.getTiles(playerEntity.getX() -  playerMoveRangePx/2, playerEntity.getY() -  playerMoveRangePx/2, playerMoveRangePx*2,  playerMoveRangePx*2);tiles.forEach(function(tile){	this.map.fill(9, tile.x, tile.y, 1, 1, this.visibilityLayer);}, this);

In this case, tile index 9 is an arbitrary green square.  


I can't seem to see the tiles I've changed in this case, and even then it's so slow it freezes up for about half a second when filling in bigger areas.


Any ideas?

Link to comment
Share on other sites



So I figured out through trial and error that map.putTile only works when you're using Canvas.  Ideally I'd like to use WebGL, as I'd like to use filters.


Is there any way to get map.putTile to function with WebGL, or some workaround?


Thanks in advance for your idea.

Link to comment
Share on other sites

Hi xerver, I'm seeing two issues:

GET http://localhost/mobilepenguins/lib/phaser-tiled/node-zlib.js.map 404 (Not Found) Uncaught TypeError: Cannot read property 'hasLoaded' of undefined 

Not sure if these issues are related.  The typeError occurs internal to Phaser.


I have followed your tutorial, this is my code:

//add the tiled plugingame.add.plugin(Phaser.Plugin.Tiled);this.cacheKey = Phaser.Plugin.Tiled.utils.cacheKey;game.load.tiledmap(this.cacheKey(this.tileMapId, 'tiledmap'), this.tileMapJson, null, Phaser.Tilemap.TILED_JSON);game.load.image(this.cacheKey(this.tileMapId, 'tileset', this.tileSetId), this.tileSetImg);

and create:

this.map = game.add.tiledmap(this.tileMapId);

Anything you can spy I'm doing wrong?


Thanks again for your help.


It appears to be happening on the this.map = game.add.tiledmap(this.tileMapId); line.


EDIT: it was an error on my end with the my IDs

Link to comment
Share on other sites


  • Recently Browsing   0 members

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