Jump to content

Creating a mini map from a render texture?


ForgeableSum
 Share

Recommended Posts

  • 3 months later...

I'd be interested in advice on this too

 

if you go here..

http://phaser.io/examples/v2/tilemaps/csv-map-with-p2

 

and paste in this code..

http://pastebin.com/RK2rs527

 

you'll see i've done a rough example of a mini map 

 

however I'm not sure this seems like a good idea:

w = layer.widthh = layer.heightm = new Matrix() // not used currently    // temporarily crop map layer for renderlayer.setFrame({x:Math.max(0,player.x-game.camera.x)-200,y:Math.max(0,player.y-game.camera.y)-200,width:400,height:400})renderTexture.render(layer, m, true)// reset layer to original dimensions (otherwise the map remains cropped)layer.setFrame({x:0, y:0, width:w, height:h})

it works but it doesn't seem like you should crop & reset it. it would be good if render()took a rectangle as an argument for the source, but I think that's from the PIXI library.

 

anybody have any suggestions?

 

thanks

j

 

Link to comment
Share on other sites

  • 3 weeks later...

I've created a version on the sandbox

http://phaser.io/sandbox/CrtqUQIr/play

 

if anybody knows how to fix my bug, I'd be grateful

renderType = "renderTexture" // slightly buggy to start, off-map area doesn't render black//renderType = "bitmapData"

you can see the renderTexture repeats into the area that should be blank

 

I'm assuming it's because i'm trying to render data that isn't actually there...  ie less than (0,0) pixel coordinates... (note the minimap is currently rotated 180 degrees, since the car is facing downwards)

 

 

bitmapData vs renderTexture: 

post-16536-0-86807700-1445541921.jpg

post-16536-0-08881100-1445541922.jpg

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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