You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ScreenManager library is a state manager at heart which allows some nifty things, like stacking multiple screens on top of each other.
It also offers hooks for most of LÖVE's callback functions. Based on the type of callback the calls are rerouted to either only the active screen (love.keypressed, love.quit, ...) or to all screens (love.resize, love.visible, ...).
Example
For a more complete example check out the example branch in this repository.
This is a simple example of how the ScreenManager should be used (note: You will have to change the paths in the example to fit your setup).
Note how MainScreen inherits from Screen.lua. This isn't mandatory, but recommended since Screen.lua already has templates for most of the callback functions.
-- MainScreen.lualocalScreen=require('lib.Screen')
localMainScreen= {}
functionMainScreen.new()
localself=Screen.new()
localx, y, w, h=20, 20, 40, 20functionself:draw()
love.graphics.rectangle('fill', x, y, w, h)
endfunctionself:update(dt)
w=w+2h=h+1endreturnselfendreturnMainScreen