Jump to content

Scaling down a tilemap layer


xerver
 Share

Recommended Posts

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();

minimap.png

 

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(); 

minimap2.png

 

Obviously not what I am looking for. Is there anyway to scale down a tilemap layer but still have it render the full layer?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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