Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with setPosition #12

Closed
flamendless opened this issue Jul 16, 2019 · 1 comment
Closed

Problem with setPosition #12

flamendless opened this issue Jul 16, 2019 · 1 comment

Comments

@flamendless
Copy link

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

@kikito
Copy link
Owner

kikito commented Jul 16, 2021

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.

@kikito kikito closed this as completed Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants