Gio,
Thanks for the info, in a nutshell, this is what I am doing when adding biome colors to map polygons.
Where should I add the sprite cache call ? In the fillCell function, or when the sprite is returned or after the sprite is attached to the scene object ?
Does it matter that I am setting up the map layer as 2d ?
// In the main app, the map draw layer is set to 2D
wade.setLayerRenderMode(wade.app.MAP_LAYER,'2d');
// then in wtgMap.js, I create a scene object to attach all the sprites to
var mSceneObject = new SceneObject(0,0,0,0);
wade.addSceneObject(mSceneObject);
// then when the map is created and colored with the biome colors
// this for loop is called for all the polygons
for (var i=0; i<mappedPolygons.length; i++) {
var cell = mappedPolygons[i];
var cellColor = DISPLAY_COLORS[cell.biome];
var fsp = self.fillCell(cell,cellColor);
/*
ADD SPRITE CACHE CALL HERE ???
fsp.cache();
*/
mSceneObject.addSprite(fsp);
/*
ADD SPRITE CACHE CALL HERE ???
fsp.cache();
*/
}; // end for mappedPolygons
// the fillCell function looks like this
this.fillCell = function(cell,fillColor) {
var fillColor = fillColor || 'red';
if (!cell) { return null; }
var fillSprite = new Sprite(0,mLayer);
fillSprite.setDrawFunction(function(context){
context.beginPath();
context.fillStyle = fillColor;
context.strokeStyle = fillColor;
context.moveTo(cell[0][0],cell[0][1]);
cell.forEach((point) => { context.lineTo(point[0],point[1]); })
context.fill();
context.stroke();
}); // end setDrawFunction
/*
ADD SPRITE CACHE CALL HERE ???
fillSprite.cache();
*/
return fillSprite;
}; // end fillCell
As usual any help you can provide is appreciated
cheers - Shri