flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
289 stars 25 forks source link

[Mouse] Allow customizing screen to slab transforms #80

Closed idbrii closed 3 years ago

idbrii commented 3 years ago

Fix #20.

Add function arg to customize screen to slab coordinates.

Improve interoperability with screen resizing libraries by allowing users to specify a function to transform screen coordinates into game coordinates.

For example, with Ulydev/push you could do:

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 = 800, 600, 1920, 1080
push:setupScreen(game_width, game_height, window_width, window_height)
Slab.Initialize(get_push_mouse, args)