Cudabear Posted November 17, 2014 Report Share Posted November 17, 2014 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? Quote Link to comment Share on other sites More sharing options...
Cudabear Posted November 18, 2014 Author Report Share Posted November 18, 2014 Okay, 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. Quote Link to comment Share on other sites More sharing options...
xerver Posted November 18, 2014 Report Share Posted November 18, 2014 You can use my tiledmap plugin that uses a sprite-per-tile technique so you can get the sprite for a tile and do anything you want to it. https://github.com/englercj/phaser-tiled Quote Link to comment Share on other sites More sharing options...
Cudabear Posted November 19, 2014 Author Report Share Posted November 19, 2014 Thank you very much! This looks like exactly what I need. I will follow up after I've had a chance to play with it. Quote Link to comment Share on other sites More sharing options...
Cudabear Posted November 19, 2014 Author Report Share Posted November 19, 2014 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 Quote Link to comment Share on other sites More sharing options...
Cudabear Posted November 19, 2014 Author Report Share Posted November 19, 2014 Okay, everything seems to be working fine. Thanks for the plugin! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.