ForgeableSum Posted June 1, 2015 Share Posted June 1, 2015 I read somewhere on here (I think it was Rich who said) that a render texture would be ideal for creating a mini map of the game world. I want to explore this option but before I do I thought I'd ask if anyone has any working examples/advice/comments on how this should be done. What say ye? jdnichollsc 1 Link to comment Share on other sites More sharing options...
jmp909 Posted September 30, 2015 Share Posted September 30, 2015 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? thanksj Nitay 1 Link to comment Share on other sites More sharing options...
jmp909 Posted October 22, 2015 Share Posted October 22, 2015 ps phaser 2.4.4 has changed slightly .. need to use this code nowhttp://pastebin.com/Gs6xDZc5 Link to comment Share on other sites More sharing options...
jmp909 Posted October 22, 2015 Share Posted October 22, 2015 I've created a version on the sandboxhttp://phaser.io/sandbox/CrtqUQIr/play if anybody knows how to fix my bug, I'd be gratefulrenderType = "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 More sharing options...
jmp909 Posted October 22, 2015 Share Posted October 22, 2015 there's also a good, but different example herehttp://www.html5gamedevs.com/topic/14182-creating-a-mini-map-in-phaser/?p=80788 they're using the tile data to fill rectangles on a bitmap as an overview of the tiles. Link to comment Share on other sites More sharing options...
Recommended Posts