Implemented the mouse scale patch on native platform
This commit is contained in:
parent
cf06bdce64
commit
01a000b9fa
4 changed files with 38 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
|||
local platform = {}
|
||||
local platform = { mouse = {} }
|
||||
|
||||
local screenWidth = 320
|
||||
local screenHeight = 200
|
||||
|
|
@ -8,6 +8,7 @@ local canvas
|
|||
function platform.init()
|
||||
love.graphics.setDefaultFilter("nearest")
|
||||
|
||||
love.graphics.setCanvas() -- Reset the canvas to avoid any bugs
|
||||
love.window.setMode(screenWidth * screenScale, screenHeight * screenScale, { resizable = false, vsync = true })
|
||||
canvas = love.graphics.newCanvas(screenWidth, screenHeight)
|
||||
end
|
||||
|
|
@ -21,4 +22,29 @@ function platform.drawEnd()
|
|||
love.graphics.draw(canvas, 0, 0, 0, screenScale, screenScale)
|
||||
end
|
||||
|
||||
local mouseGetX = function()
|
||||
return platform.mouse._ogMouseGetX() / screenScale
|
||||
end
|
||||
if mouseGetX ~= love.mouse.getX then
|
||||
platform.mouse._ogMouseGetX = love.mouse.getX
|
||||
love.mouse.getX = mouseGetX
|
||||
end
|
||||
|
||||
local mouseGetY = function()
|
||||
return platform.mouse._ogMouseGetY() / screenScale
|
||||
end
|
||||
if mouseGetY ~= love.mouse.getY then
|
||||
platform.mouse._ogMouseGetY = love.mouse.getY
|
||||
love.mouse.getY = mouseGetY
|
||||
end
|
||||
|
||||
local mouseGetPosition = function()
|
||||
local x, y = platform.mouse._ogMouseGetPosition()
|
||||
return x / screenScale, y / screenScale
|
||||
end
|
||||
if mouseGetPosition ~= love.mouse.getPosition then
|
||||
platform.mouse._ogMouseGetPosition = love.mouse.getPosition
|
||||
love.mouse.getPosition = mouseGetPosition
|
||||
end
|
||||
|
||||
return platform
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue