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
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,8 +199,29 @@ You can access the timer objects throught `stage.getTimer()` or
199
199
| API | Example | Description |
200
200
| :-: | :-: | :-: |
201
201
|`void getMillis()`|`cat.getMillis()`| Returns the milliseconds since the sprite was created |
202
-
|`boolean everyMillis(int)`|`stage.everyMillis(2000)`| Returns true **roughly** every 2000 Milliseconds |
203
-
|`void reset()`|`dog.reset()`| Resets a timer back to 0 |
202
+
|`boolean everyMillis(int)`|`stage.everyMillis(600)`| Returns true every 600 Milliseconds |
203
+
|`boolean forMillis(int)`|`dog.forMillis(600)`| Returns true for the first 600 Milliseconds |
204
+
|`boolean afterMillis(int)`|`cat.afterMillis(600)`| Returns true after the first 600 Milliseconds |
205
+
|`boolean intervalMillis(int)`|`cat.intervalMillis(600)`| Returns toggles between true and false every 600 Milliseconds starting with false |
206
+
|`boolean intervalMillis(int, boolean)`|`cat.intervalMillis(600, true)`| Returns toggles between true and false every 600 Milliseconds starting with true |
207
+
|`boolean intervalMillis(int, int)`|`cat.intervalMillis(600, 200)`| Returns toggles between true for 600 Milliseconds and false for 200 Milliseconds starting with false |
208
+
|`boolean intervalMillis(int, int, boolean)`|`cat.intervalMillis(600, 200, true)`| Returns toggles between true for 600 Milliseconds and false for 200 Milliseconds starting with true |
209
+
210
+
For a visual example of these methods see example [Timer](#Timer) or the gif
211
+
below. A dot represents the return of true.
212
+
213
+

214
+
215
+
```
216
+
everyMillis(600) -> orange (first line)
217
+
forMillis(600) -> lime (second line)
218
+
afterMillis(600) -> green (third line)
219
+
intervalMillis(600) -> skyblue (fourth line)
220
+
intervalMillis(600, true) -> blue (fifth line)
221
+
intervalMillis(600, 300) -> pink (sixth line)
222
+
intervalMillis(600, 300, true) -> red (seventh line)
223
+
```
224
+
204
225
205
226
If you want that a sprite should do something every 2000ms and every 1000ms,
206
227
you need two timers. To add a timer you simply call
@@ -297,12 +318,21 @@ An example which makes use of timers.
0 commit comments