Jump to content

Tilemap Highlighting


Cudabear
 Share

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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