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
Stage.stageToScreenCoordinates returns incorrect value with y offset in viewport #5854
Comments
This is unrelated to the #5853 |
With reference to the example code:
(0,0) is within the bounds of the window. Why is it returning (0,-50) which is outside the window? |
Yeah, this doesn't look right. Why do you expect 0,25 though? |
Relevant camera.project documentation:
Relevant code:
stageToScreenCoordinates code, which uses viewport.screenHeight to convert the origin:
|
stage.stageToScreenCoordinates shouldn't have origin at top left, so it shouldn't be 0,25. Screen is bottom left unless otherwise specified, and project is sticking to this standard. As with the previous issue, the documentation probably needs improving here also. Anyway, this result seems wrong, so will have to do further testing. |
I reasoned this from the way the source code and actual tests work, specifically this line It works perfectly fine, returning correct result with origin top left if viewport has no offset. [edit] actually origin top left is used almost everywhere: viewport.toScreenCoordinates (origin top left)
camera.unproject (origin top left)
|
Didn't mean for this to get closed (happened via GH's automatic magicke). |
Issue details
Stage.stageToScreenCoordinates returns incorrect value with y offset in viewport
Reproduction steps/code
Create a 100x100 window.
Setup a stage with a viewport in the top quarter of the window i.e. width 100, height 25, y=75
stage.stageToScreenCoordinates returns incorrect values.
Due to the following line in Stage:
libgdx/gdx/src/com/badlogic/gdx/scenes/scene2d/Stage.java
Line 738 in c0c1f51
After getting the result of camera.project (in absolute screen coordinates with origin at bottom left), it converts to top left origin using viewport.screenHeight instead of actual window height.
Version of LibGDX and/or relevant dependencies
1.9.10
The text was updated successfully, but these errors were encountered: