Skip to content

Commit f0e1d76

Browse files
committed
update readme
1 parent 8e0db4a commit f0e1d76

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

license.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Andrew Minnich
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

readme.md

+20-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roomy
22

3-
**Roomy** is a screen management library for LÖVE. It facilitates organizing game code by the different "screens" in the game, such as the title screen, gameplay screen, and pause screen.
3+
**Roomy** is a screen management library for LÖVE. It helps organize game code by the different "screens" in the game, such as the title screen, gameplay screen, and pause screen.
44

55
## Installation
66

@@ -15,7 +15,7 @@ local roomy = require 'path.to.roomy' -- if it's in subfolders
1515

1616
### Defining screens
1717

18-
A screen is defined as a table with self functions for each event it should respond to. For example, a gameplay screen may look like this:
18+
A screen is defined as a table with functions for each event it should respond to. For example, a gameplay screen may look like this:
1919

2020
```lua
2121
local gameplay = {}
@@ -82,23 +82,13 @@ function game:keypressed(key)
8282
end
8383
```
8484

85-
### Applying screen changes
86-
87-
```lua
88-
manager:apply()
89-
```
90-
91-
Calling `switch`, `push`, and `pop` does not apply screen changes immediately. Rather, they are queued up and applied all at once when `apply` is called. Placing `manager.apply` at a specific point in the game loop (right before updating, for instance) alleviates some potential issues with inputs meant for one screen being sent to another screen.
92-
93-
Note that if you use `manager.hook`, you don't need to call this manually.
94-
9585
### Emitting events
9686

9787
```lua
9888
manager:emit(event, ...)
9989
```
10090

101-
Calls `screen:[event]` on the active screen if that function exists.
91+
Calls `screen:[event]` on the active screen if that function exists. Additional arguments are passed to `screen.event`.
10292

10393
### Hooking into LÖVE callbacks
10494

@@ -107,59 +97,58 @@ manager:hook(options)
10797
```
10898

10999
Adds code to the LÖVE callbacks to emit events for each callback (previously defined behavior will be preserved). `options` is an optional table with the following keys:
110-
- `applyBefore` - the name of the callback to run `manager:apply()` at the start of. Set this to `false` to disable this behavior. Defaults to `update`.
111-
- `callbacks` - a list of callbacks to hook into. Defaults to all LÖVE callbacks (except for `errhand`).
112-
- `skip` - a list of callbacks not to hook into. If defined, all LÖVE callbacks will be hooked except for the ones in this list. Note that you will get an error if you define both `callbacks` and `skip`.
100+
- `include` - a list of callbacks to hook into. If this is defined, *only* these callbacks will be overridden.
101+
- `exclude` - a list of callbacks *not* to hook into. If this is defined, all of the callbacks except for these ones will be overridden.
113102

114-
As an example, the following code will cause the screen manager to hook into every callback except for `keypressed` and `mousepressed`, and screen changes will be applied at the beginning of `love.draw`.
103+
As an example, the following code will cause the screen manager to hook into every callback except for `keypressed` and `mousepressed`.
115104

116105
```lua
117106
manager:hook {
118-
skip = {'keypressed', 'mousepressed'},
119-
applyBefore = 'draw',
107+
exclude = {'keypressed', 'mousepressed'},
120108
}
121109
```
122110

111+
**Note:** because this function overrides the LOVE callbacks, you'll want to call this *after* you've defined them. I recommend using this function in the body of `love.load`, like this:
112+
113+
```lua
114+
function love.load()
115+
manager:hook()
116+
manager:switch(gameplay)
117+
end
118+
```
119+
123120
### Screen callbacks
124121

125122
Screens have a few special callbacks that are called when a screen is switched, pushed, or popped.
126123

127124
```lua
128125
function screen:enter(previous, ...) end
129126
```
127+
130128
Called when a manager switches *to* this screen or if this screen is pushed on top of another screen.
131129
- `previous` - the previously active screen, or `false` if there was no previously active screen
132130
- `...` - additional arguments passed to `manager.switch` or `manager.push`
133131

134132
```lua
135133
function screen:leave(next, ...) end
136134
```
135+
137136
Called when a manager switches *away from* this screen or if this screen is popped from the stack.
138137
- `next` - the screen that will be active next
139138
- `...` - additional arguments passed to `manager.switch` or `manager.pop`
140139

141140
```lua
142141
function screen:pause(next, ...) end
143142
```
143+
144144
Called when a screen is pushed on top of this screen.
145145
- `next` - the screen that was pushed on top of this screen
146146
- `...` - additional arguments passed to `manager.push`
147147

148148
```lua
149149
function screen:resume(previous, ...) end
150150
```
151+
151152
Called when a screen is popped and this screen becomes active again.
152153
- `previous` - the screen that was popped
153154
- `...` - additional arguments passed to `manager.pop`
154-
155-
## License
156-
157-
MIT License
158-
159-
Copyright (c) 2019 Andrew Minnich
160-
161-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
162-
163-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
164-
165-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)