kikito/gamera

Problem with setPosition

flamendless opened this issue · 1 comments

i need help with this:

--init
local active_camera = Gamera.new(0, 0, 1024, 512)

--in draw
local screen_x, screen_y, screen_w, screen_h = active_camera:getWindow()
local world_x, world_y, world_w, world_h = active_camera:getWorld()
local dx = Imgui.SliderInt("x", screen_x, 0, world_w)
local dy = Imgui.SliderInt("y", screen_y, 0, world_h)
print(dx, dy) --works
active_camera:setPosition(dx, dy)
print(active_camera:getWindow()) --should be updated, but prints 0, 0, 1024, 512 still

the position value of the window should change, but it returns to 0 :/

setPosition changes the x and y position of the Window (subset of World), but it resets to 0

ive tried

active_camera.x = dx
active_camera.y = dy

but instead of resetting to 0, it resets to 512 (half of 1024), because internally gamera computes position and width since (0,0) in camera coordinates is center

Sent from my HUAWEI GR5 2017 using FastHub

I think you misunderstood what position is and what window is in gamera.

Imagine a news reporter moving around on his car, shooting footage with their camera. And then imagine a person sitting on their living room, watching the news on their TV.

  • The coordinates the news camera is looking at is position.
  • The coordinates of the person watching the news on their living room is the window.

They are related, in a way, but not in the way you are thinking. If the position changes, the content showed on the window will change, but the window will not move.