Skip to content

Commit

Permalink
[Mouse] Read mouse arguments out of Args table
Browse files Browse the repository at this point in the history
Fix flamendless#20. Related to flamendless#80.

The function arg to customize screen to slab coordinates isn't passed
from Slab.Initialize -- it only passes the input table.

Usage with push.lua:

    function love.load(args)
        local function get_push_mouse(x,y)
            local new_x,new_y = push:toGame(x,y)
            if new_x and new_y then
                return new_x,new_y
            end
            return x,y
        end
        local game_width, game_height, window_width, window_height = 320, 240, 1280, 720
        push:setupScreen(game_width, game_height, window_width, window_height)
        args.TransformPointToSlab = get_push_mouse
        Slab.Initialize(args)
    end

    function love.draw()
        push:start()
            Slab.Draw()
        push:finish()
    end
  • Loading branch information
idbrii committed Aug 7, 2021
1 parent 5fb76d3 commit 79c7d58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Internal/Input/Mouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ local function ProcessEvents()
Events = {}
end

function Mouse.Initialize(Args, TransformPointToSlab)
TransformPoint = TransformPointToSlab or TransformPoint
function Mouse.Initialize(Args)
TransformPoint = Args.TransformPointToSlab or TransformPoint

MouseMovedFn = love.handlers['mousemoved']
MousePressedFn = love.handlers['mousepressed']
Expand Down

0 comments on commit 79c7d58

Please sign in to comment.