Jump to content

Creating a mini map from a render texture?


Recommended Posts

  • 3 months later...

I'd be interested in advice on this too


if you go here..



and paste in this code..



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?





Link to comment
Share on other sites

  • 3 weeks later...

I've created a version on the sandbox



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: 



Link to comment
Share on other sites


  • Recently Browsing   0 members

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