beancoder Posted July 22, 2014 Share Posted July 22, 2014 I have the following code.var color = bitmap.getPixel32(Math.round(nodes.x),Math.round(nodes.y)); Now I want to implement the same thing in Tilemap instead of bitmap! I triedvar color = tilemap.getPixel32(Math.round(nodes.x),Math.round(nodes.y)); but didn't work. Any idea? Link to comment Share on other sites More sharing options...
lewster32 Posted July 22, 2014 Share Posted July 22, 2014 You can access the relevant layer's canvas property to get a bitmap representation which you can then use to pick the colour of a pixel from - you'll have to look up how you do that with canvas as opposed to a BitmapData instance as it'll be slightly different and less intuitive. Each layer of a tilemap is rendered separately to a canvas, and then the tilemap draws them all one on top of another. Link to comment Share on other sites More sharing options...
beancoder Posted July 22, 2014 Author Share Posted July 22, 2014 Okay thanks.. I am new to phaser so need a simpler method. Or maybe some example. Link to comment Share on other sites More sharing options...
lewster32 Posted July 22, 2014 Share Posted July 22, 2014 This isn't really Phaser, it's more about canvas. Once you've got the canvas property from your TilemapLayer, the rest is working with canvas and that's beyond the scope of this forum really. Take a look at this maybe, paying attention to the last part about grabbing pixels from a canvas: http://tutorials.jenkov.com/html5-canvas/pixels.html Link to comment Share on other sites More sharing options...
Recommended Posts