xerver Posted August 30, 2014 Share Posted August 30, 2014 Hey all, I have a small map that is 64 tiles by 64 tiles, each tile is 8 x 8 pixels (making the map 512 x 512). My canvas is 256 x 256, and I want this entire map to fit within the rendered area. When I render the layer normally this is what I get:var layer = level.createLayer(layerData.name, null, null, group);layer.visible = layerData.visible;layer.alpha = layerData.opacity;layer.position.set(layerData.x, layerData.y);layer.resizeWorld(); That is expected, so what I want to do is scale the layer down by half. Basically I want it to render each 8x8 tile as if it was a 4x4 tile, but when I scale the layer this is what I get:var layer = level.createLayer(layerData.name, null, null, group);layer.visible = layerData.visible;layer.alpha = layerData.opacity;layer.position.set(layerData.x, layerData.y);layer.scale.set(0.5, 0.5);layer.resizeWorld(); Obviously not what I am looking for. Is there anyway to scale down a tilemap layer but still have it render the full layer? InsOp 1 Link to comment Share on other sites More sharing options...
wayfinder Posted August 30, 2014 Share Posted August 30, 2014 Try making the world larger before you add the tilemap layer Link to comment Share on other sites More sharing options...
xerver Posted August 31, 2014 Author Share Posted August 31, 2014 I don't think that will make a difference because the canvas that draws the layer wouldn't get any bigger in that instance. I was able to get it to work properly by multiplying the width/height passed to `createLayer` by the inverse of the scale (in this case 2):var layer = level.createLayer( layerData.name, layerData.width * levelData.tilewidth * 2, layerData.height * levelData.tileheight * 2, group);layer.visible = layerData.visible;layer.alpha = layerData.opacity;layer.position.set(layerData.x, layerData.y);layer.scale.set(0.5, 0.5);layer.resizeWorld(); This works OK as a workaround, but I really feel this should be automatic. After digging further I found this github issue which seems to suggest scaling tilemap layers isn't yet officially supported. Hopefully I can get more information on this soon. InsOp 1 Link to comment Share on other sites More sharing options...
rich Posted August 31, 2014 Share Posted August 31, 2014 There's currently no support for scaling (or rotation) of Tilemaps. To be honest the renderer needs sorting out first (as I explained in detail in that github issue) and I feel only after this point can we then look at adding scaling and rotation - and even after that is done it will be a challenge to get collision and the camera working properly in a multi-mixed scaled map to say the least. Even so, one thing at a time... Link to comment Share on other sites More sharing options...
xerver Posted August 31, 2014 Author Share Posted August 31, 2014 Makes sense, thanks for the heads up rich. Luckily this map I need to scale actually has no collisions (it is just a minimap) so it should be fine. Thanks man! Link to comment Share on other sites More sharing options...
rich Posted September 1, 2014 Share Posted September 1, 2014 Yeah that should make life easier at least I really want to get some time to try out using a RenderTexture for the map, as I'm positive that will have a marked improvement in performance on WebGL. Link to comment Share on other sites More sharing options...
Recommended Posts