Sorry for the confusion, I meant:
- wade.iso.getTerrainLayerId() returns a number, the layer id, as you said
- wade.getSpritesInArea(area, layer) is a function of the core WADE module, not the isometric module (that's why it isn't in the isometric documentation :) )
In fact, there is no reason to limit this to isometric games only - you could do it so that you pass in one or more layer id's and a radius, and it draws a map of everything that's in those layers and within the radius.
Regarding drawToImage - I know it can be a bit confusing, but it's a really powerful feature. The idea is that you draw to a sprite to an image, like this:
mySprite.drawToImage('test.png')
Which will draw your sprite to 'test.png. The point is that 'test.png' isn't necessarily a file on your disk - it doesn't need to be a physical file at all. You could use any name for the image you are drawing to, it isn't actually going to physically create or write to a file - that's why it's a virtual path. But you can then use this image as if it was a real image, to create new sprites. The cool thing is that you can draw to an image multiple times without necessarily having to clear what's there. You can use a second parameter (a boolean) to tell WADE that you want to completely overwrite the image with that name (true), or just write on top of it (false).
You can the pass a few additional parameters to this function, if you want to customize the drawing process: you can change the scale and position, rotation, skew and blend mode. In your case, you only care about the scale and position.
So something along the lines of this:
var generateMap = function(layerId, radius){ // create a transparent sprite that's as big as the map var transparent = new Sprite(); transparent.setDrawFunction(function() {}); // set a draw function that does nothing, it's a transparent sprite transparent.setSize(miniMapSize.x, miniMapSize.y); // draw the transparent sprite to our target image, overwriting anything that's there // the true parameter implies taht the 'miniMap' image, if it exists, will be destroyed and re-created. transparent.drawToImage('miniMap', true); // define an area around the camera var cameraPosition = wade.getCameraPosition(); var area = {minX: cameraPosition.x - radius, minY: cameraPosition.y - radius); // get an array of sprites in the area var sprites = wade.getSpritesInArea(area, layerId); // draw all the sprites to the miniMap image (without recreating the 'miniMap' image) for (var i=0; i<sprites.length; i++) { // work out position and size and draw to the image ...... sprites[i].drawToImage('miniMap', false, ...... ) } }
After generating the map, when you want to use it, you simply do:
var mapSprite = new Sprite('miniMap');
This is just an example, but in reality it would be nice to have the option to use an array of layerId's, and be able to customize the map as much as possible (different width and height, but also different shapes)