Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rm-code/screenmanager
Stackable Screen/State Management for the LÖVE framework.
https://github.com/rm-code/screenmanager
love2d lua screenmanager state-management
Last synced: 3 months ago
JSON representation
Stackable Screen/State Management for the LÖVE framework.
- Host: GitHub
- URL: https://github.com/rm-code/screenmanager
- Owner: rm-code
- License: zlib
- Created: 2015-03-24T10:14:00.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-11-20T11:07:39.000Z (about 7 years ago)
- Last Synced: 2024-10-21T07:06:50.226Z (3 months ago)
- Topics: love2d, lua, screenmanager, state-management
- Language: Lua
- Homepage: http://rm-code.github.io/screenmanager/
- Size: 77.1 KB
- Stars: 32
- Watchers: 3
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-love2d - ScreenManager - Screen/State Management for the LÖVE framework. (Helpers)
README
# ScreenManager
[![Version](https://img.shields.io/badge/Version-2.1.1-blue.svg)](https://github.com/rm-code/screenmanager/releases/latest)
[![LOVE](https://img.shields.io/badge/L%C3%96VE-0.10.2-EA316E.svg)](http://love2d.org/)
[![License](http://img.shields.io/badge/Licence-zlib-brightgreen.svg)](LICENSE.md)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](https://github.com/rm-code/screenmanager/tree/example) 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).
```lua
-- main.lualocal ScreenManager = require('lib.ScreenManager')
function love.load()
local screens = {
main = require('src.screens.MainScreen')
}ScreenManager.init(screens, 'main')
endfunction love.draw()
ScreenManager.draw()
endfunction love.update(dt)
ScreenManager.update(dt)
end
```
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.```lua
-- MainScreen.lualocal Screen = require('lib.Screen')
local MainScreen = {}
function MainScreen.new()
local self = Screen.new()local x, y, w, h = 20, 20, 40, 20
function self:draw()
love.graphics.rectangle('fill', x, y, w, h)
endfunction self:update(dt)
w = w + 2
h = h + 1
endreturn self
endreturn MainScreen
```## Documentation
An online documentation is available [here](http://rm-code.github.io/screenmanager/).