Skip to content
New issue

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

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

Already on GitHub? # to your account

CATROID-1481 Fix bug in 'Single tap at' brick #5038

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dorianpercic
Copy link
Contributor

@dorianpercic dorianpercic commented Sep 27, 2024

https://catrobat.atlassian.net/browse/CATROID-1481
When brick coordinates added and read with e.g. 'Show variable' brick at runtime, then the x and y coordinate had one value less than previously assigned.
This is a bug in the libgdx library. In our version of libgdx the Camera.unproject() method, with which we come from the screen coordinates back to the stage coordinates, calculates y like that: y = Gdx.graphics.getHeight() - y - 1;. The -1 is unnecessary and in the Camera.project() function, it is not added to the worldcoordinates. However in the new version of libgdx, y is calculated like that: y = Gdx.graphics.getHeight() - screenCoords.y - viewportY;, which would be correct (see https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/Camera.java#L195C1-L195C99). In this bug fix I just added +1 to the y coordinate when touch is applied. Furthermore I applied Math.round() for both x and y, in order to fix rounding errors on the one hand and on the other fix the off-by-one error for the x coordinate.

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

When brick coordinates added and read with e.g. 'Show variable' brick at
runtime, then the x and y coordinate had one value less than previously
assigned.
@dorianpercic dorianpercic self-assigned this Sep 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant