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
Copy file name to clipboardExpand all lines: readme.md
+28-28
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Roomy
2
2
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.
3
+
**Roomy** is a scene 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.
4
4
5
5
## Installation
6
6
@@ -13,9 +13,9 @@ local roomy = require 'path.to.roomy' -- if it's in subfolders
13
13
14
14
## Usage
15
15
16
-
### Defining screens
16
+
### Defining scenes
17
17
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:
18
+
A scene is defined as a table with functions for each event it should respond to. For example, a gameplay scene may look like this:
19
19
20
20
```lua
21
21
localgameplay= {}
@@ -37,32 +37,32 @@ function gameplay:draw()
37
37
end
38
38
```
39
39
40
-
A screen table can contain anything, but it will likely have some combination of functions corresponding to LÖVE callbacks and Roomy events.
40
+
A scene table can contain anything, but it will likely have some combination of functions corresponding to LÖVE callbacks and Roomy events.
41
41
42
-
### Creating a screen manager
42
+
### Creating a scene manager
43
43
44
44
```lua
45
45
localmanager=roomy.new()
46
46
```
47
47
48
-
Creates a new screen manager. You can create as many screen managers as you want, but you'll most likely want one global manager for the main screens of your game.
48
+
Creates a new scene manager. You can create as many scene managers as you want, but you'll most likely want one global manager for the main scenes of your game.
49
49
50
-
### Switching screens
50
+
### Switching scenes
51
51
52
52
```lua
53
-
manager:enter(screen, ...)
53
+
manager:enter(scene, ...)
54
54
```
55
55
56
-
Changes the currently active screen.
56
+
Changes the currently active scene.
57
57
58
-
### Pushing/popping screens
58
+
### Pushing/popping scenes
59
59
60
60
```lua
61
-
manager:push(screen, ...)
61
+
manager:push(scene, ...)
62
62
manager:pop()
63
63
```
64
64
65
-
Managers use a stack to hold screens. You can push a screen onto the top of the stack, making it the currently active screen, and then pop it, resuming the previous state where it left off. This is useful for implementing pause screens, for example:
65
+
Managers use a stack to hold scenes. You can push a scene onto the top of the stack, making it the currently active scene, and then pop it, resuming the previous state where it left off. This is useful for implementing pause screens, for example:
66
66
67
67
```lua
68
68
localpause= {}
@@ -88,7 +88,7 @@ end
88
88
manager:emit(event, ...)
89
89
```
90
90
91
-
Calls `screen:[event]` on the active screen if that function exists. Additional arguments are passed to `screen.event`.
91
+
Calls `scene:[event]` on the active scene if that function exists. Additional arguments are passed to `scene.event`.
92
92
93
93
### Hooking into LÖVE callbacks
94
94
@@ -100,7 +100,7 @@ Adds code to the LÖVE callbacks to emit events for each callback (previously de
100
100
-`include` - a list of callbacks to hook into. If this is defined, *only* these callbacks will be overridden.
101
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.
102
102
103
-
As an example, the following code will cause the screen manager to hook into every callback except for `keypressed` and `mousepressed`.
103
+
As an example, the following code will cause the scene manager to hook into every callback except for `keypressed` and `mousepressed`.
104
104
105
105
```lua
106
106
manager:hook {
@@ -117,38 +117,38 @@ function love.load()
117
117
end
118
118
```
119
119
120
-
### Screen callbacks
120
+
### Scene callbacks
121
121
122
-
Screens have a few special callbacks that are called when a screen is switched, pushed, or popped.
122
+
Scenes have a few special callbacks that are called when a scene is switched, pushed, or popped.
123
123
124
124
```lua
125
-
functionscreen:enter(previous, ...) end
125
+
functionscene:enter(previous, ...) end
126
126
```
127
127
128
-
Called when a manager switches *to* this screen or if this screen is pushed on top of another screen.
129
-
-`previous` - the previously active screen, or `false` if there was no previously active screen
128
+
Called when a manager switches *to* this scene or if this scene is pushed on top of another scene.
129
+
-`previous` - the previously active scene, or `false` if there was no previously active scene
130
130
-`...` - additional arguments passed to `manager.switch` or `manager.push`
131
131
132
132
```lua
133
-
functionscreen:leave(next, ...) end
133
+
functionscene:leave(next, ...) end
134
134
```
135
135
136
-
Called when a manager switches *away from* this screen or if this screen is popped from the stack.
137
-
-`next` - the screen that will be active next
136
+
Called when a manager switches *away from* this scene or if this scene is popped from the stack.
137
+
-`next` - the scene that will be active next
138
138
-`...` - additional arguments passed to `manager.switch` or `manager.pop`
139
139
140
140
```lua
141
-
functionscreen:pause(next, ...) end
141
+
functionscene:pause(next, ...) end
142
142
```
143
143
144
-
Called when a screen is pushed on top of this screen.
145
-
-`next` - the screen that was pushed on top of this screen
144
+
Called when a scene is pushed on top of this scene.
145
+
-`next` - the scene that was pushed on top of this scene
146
146
-`...` - additional arguments passed to `manager.push`
147
147
148
148
```lua
149
-
functionscreen:resume(previous, ...) end
149
+
functionscene:resume(previous, ...) end
150
150
```
151
151
152
-
Called when a screen is popped and this screen becomes active again.
153
-
-`previous` - the screen that was popped
152
+
Called when a scene is popped and this scene becomes active again.
153
+
-`previous` - the scene that was popped
154
154
-`...` - additional arguments passed to `manager.pop`
0 commit comments