Dusk, zooming the camera

Is there a way to set the zoom of the camera or the view? I mean that now the view distance is based on tile size? I use 64x64 tiles, but I would like to have the camera a bit more closer to the player.

You can change the size of the screen in the config if thats what your asking…

Good Luck!

That’s not exactly what I mean, 'cause config.lua affects the whole view (control buttons and so on). I tried to draw what I mean. In the right pic the camera is closer to the player.

example.jpg

https://coronalabs.com/blog/2013/01/22/implementing-pinch-zoom-rotate/

You should read that blog…

Good Luck!

To change the zoom, you should be able just to use map:scale() or map.xScale/yScale = x/y.

map:scale(2, 2)
  • Caleb

Thanks - and everything seemed ok, but then I realized that the physics bodies of the tiles are not scaled. How this could be fixed? scale.jpg

EDIT: What if you could set the camera zoom level, for example: map.setCameraZoomLevel()

Unfortunately, Box2D physics bodies do not scale with display groups. This is a fundamental limit of Corona, so the answer is pretty much “it can’t be fixed.” Sorry about that :(.

  • Caleb

Is it possible that we could set the zoom level? We can control the camera with DUSK methods, but there isn’t one for zooming.

Resizing potentially hundreds of physics bodies would be really, really slow, so there isn’t a Dusk solution to this currently. Can you get past this issue by scaling your colliding object rather than the tiles?

  • Caleb

probably needs testing:  as you probably DON’T want to scale the physics bodies…  everything is probably still fine as is, it’ll just LOOK wrong in the hybrid or debug draw modes because those modes DON’T scale/rotate/translate with display groups - the underlying model of the physics world is still probably internally consistent tho.  (assuming of course that Dusk’s “camera zoom” is accomplished just via display group scaling)

@davebollinger

Just tested what you said and you are right. It’s just the draw mode that looks wrong :slight_smile:

@davebollinger:

Good thinking! I didn’t even consider that. Also saves a lot of useless work for me - building a whole scaling method only to find it was unneeded :).

  • Caleb

You can change the size of the screen in the config if thats what your asking…

Good Luck!

That’s not exactly what I mean, 'cause config.lua affects the whole view (control buttons and so on). I tried to draw what I mean. In the right pic the camera is closer to the player.

example.jpg

https://coronalabs.com/blog/2013/01/22/implementing-pinch-zoom-rotate/

You should read that blog…

Good Luck!

To change the zoom, you should be able just to use map:scale() or map.xScale/yScale = x/y.

map:scale(2, 2)
  • Caleb

Thanks - and everything seemed ok, but then I realized that the physics bodies of the tiles are not scaled. How this could be fixed? scale.jpg

EDIT: What if you could set the camera zoom level, for example: map.setCameraZoomLevel()

Unfortunately, Box2D physics bodies do not scale with display groups. This is a fundamental limit of Corona, so the answer is pretty much “it can’t be fixed.” Sorry about that :(.

  • Caleb

Is it possible that we could set the zoom level? We can control the camera with DUSK methods, but there isn’t one for zooming.

Resizing potentially hundreds of physics bodies would be really, really slow, so there isn’t a Dusk solution to this currently. Can you get past this issue by scaling your colliding object rather than the tiles?

  • Caleb