feat(screen): add a way to get coordinate and scale
This commit is contained in:
parent
208c523248
commit
1c8c2d6937
3 changed files with 18 additions and 0 deletions
|
@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- **examples:** Test all player number and camera types
|
- **examples:** Test all player number and camera types
|
||||||
|
|
||||||
|
- **core.screen:** Add a way to get coordinate and scale
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors
|
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors
|
||||||
|
|
|
@ -87,6 +87,14 @@ function CScreen.project(x, y)
|
||||||
return math.floor((x - tx) / fsv), math.floor((y - ty) / fsv)
|
return math.floor((x - tx) / fsv), math.floor((y - ty) / fsv)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CScreen.getScale()
|
||||||
|
return fsv
|
||||||
|
end
|
||||||
|
|
||||||
|
function CScreen.getScreenCoordinate(x, y)
|
||||||
|
return math.floor((x + tx) * fsv), math.floor((y + ty) * fsv)
|
||||||
|
end
|
||||||
|
|
||||||
-- Change letterbox color
|
-- Change letterbox color
|
||||||
function CScreen.setColor(r, g, b, a)
|
function CScreen.setColor(r, g, b, a)
|
||||||
cr = r
|
cr = r
|
||||||
|
|
|
@ -66,6 +66,14 @@ function ScreenManager:getMousePosition()
|
||||||
return CScreen.project(love.mouse.getX(), love.mouse.getY())
|
return CScreen.project(love.mouse.getX(), love.mouse.getY())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ScreenManager:getScale()
|
||||||
|
return CScreen.getScale()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScreenManager:getScreenCoordinate(x, y)
|
||||||
|
return CScreen.getScreenCoordinate(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
-- INFO FUNCTIONS
|
-- INFO FUNCTIONS
|
||||||
-- Get screen informations
|
-- Get screen informations
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue