Get bounds once zoom has been set with Ortographic camera (SOLVED)

Getting bounds immediately after setting zoom doesn’t work, because set_zoom sends a message and is therefore actioned next frame:

local zoom = 0.25
camera.set_zoom(camera_id, zoom)
local bounds = camera.screen_to_world_bounds(camera_id)	

I tried to delay triggering the screen_to_world_bounds() with a message, but it doesn’t work (the zoom still isn’t changed when the “get_camera_bounds” message is received):

local zoom = 0.25
camera.set_zoom(camera_id, zoom)
msg.post(".", "get_camera_bounds") -- Triggering screen_to_world_bounds()

What’s the best way to accomplish this? I was going to use a timer, but then a thousand warning bells went off in my mind. :slight_smile:

Can you please open a ticket on GitHub for this as well?

Maybe there should be some kind of listener system that could be connected to the camera to give you updates when properties have changed? Hmm…

2 Likes

Yes! Thanks for listening! :slight_smile:

https://github.com/britzl/defold-orthographic/issues/27

1 Like