Jump to content

beancoder
 Share

Recommended Posts

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 tried

var color = tilemap.getPixel32(Math.round(nodes.x),Math.round(nodes.y));

 

but didn't work.  :(

 

Any idea?

 

Link to comment
Share on other sites

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

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

 Share

  • Recently Browsing   0 members

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