diff --git a/CHANGELOG.md b/CHANGELOG.md index 22007f5..e3350ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **examples:** Add missing translations +- **camera:** Fix onscreen coordinates by using new core.screen func + ### Removed - **actor:** Remove all function related to XGravity diff --git a/gamecore/modules/world/camera/init.lua b/gamecore/modules/world/camera/init.lua index 49ff883..02019d3 100644 --- a/gamecore/modules/world/camera/init.lua +++ b/gamecore/modules/world/camera/init.lua @@ -232,8 +232,10 @@ function CameraSystem:getOnScreenViewCoordinate(id) viewx = (basex) + view.pos.onScreen.x - (self.views.width / 2) viewy = (basey) + view.pos.onScreen.y - (self.views.height / 2) - vieww = self.views.width - viewh = self.views.height + viewx, viewy = core.screen:getScreenCoordinate(viewx, viewy) + + vieww = self.views.width * core.screen:getScale() + viewh = self.views.height * core.screen:getScale() return viewx, viewy, vieww, viewh end @@ -245,7 +247,7 @@ function CameraSystem:getOnScreenViewRelativePosition(id) viewx = view.pos.onScreen.x viewy = view.pos.onScreen.y - return viewx, viewy + return core.screen:getScreenCoordinate(viewx, viewy) end function CameraSystem:getOnScreenViewCenter(id) @@ -256,13 +258,13 @@ function CameraSystem:getOnScreenViewCenter(id) viewx = (basex) + view.pos.onScreen.x viewy = (basey) + view.pos.onScreen.y - return viewx, viewy + return core.screen:getScreenCoordinate(viewx, viewy) end function CameraSystem:getViewScale(id) local cam = self:getViewCam(id) - return cam.scale + return cam.scale * core.screen:getScale() end function CameraSystem:limitView(id)