|
1 | 1 | # Pause and Game Over Scripts
|
2 | 2 |
|
3 |
| -## Pause |
4 |
| -To entirely overwrite the existing menu with one you make yourself from scratch, put the following line inside a gameplay script; |
| 3 | +### Pause Scripts |
| 4 | +Pause Scripts can change the pause menu, either entirely or tiny bits of it.<br> |
| 5 | +To use one, you have to load it from a Script *(any script can do, even Song Scripts)*. |
5 | 6 | ```hx
|
6 | 7 | PauseSubState.script = 'data/scripts/pause';
|
7 | 8 | ```
|
| 9 | +This code points to the script that can be found in ``./data/scripts/`` and is called ``pause.hx``. |
8 | 10 |
|
9 |
| -Then, in `data/scripts/pause.hx`, paste this in as a template. |
| 11 | +You can do many things in this script. For example, this is how you can override it and have your own entirely custom pause menu here: |
10 | 12 | ```hx
|
11 |
| -function create(e){ |
12 |
| - e.cancel(); |
| 13 | +function create(event){ |
| 14 | + event.cancel(); |
13 | 15 |
|
14 | 16 | camera = pauseCam = new FlxCamera();
|
15 | 17 | pauseCam.bgColor = FlxColor.TRANSPARENT;
|
16 | 18 | FlxG.cameras.add(pauseCam, false);
|
17 | 19 |
|
18 |
| - // your code goes below this line |
| 20 | + // your code here |
19 | 21 | }
|
20 | 22 | ```
|
21 |
| -This script will prevent the base pause menu from loading and allow you to add whatever you want to it. |
| 23 | +*(``create``'s event has more parameters than that. Check for <a href="./All of the script calls.md">All of the script calls</a>, and for calls other than ``create``)*<br> |
| 24 | +This script will prevent the base pause menu from loading and allows you to add whatever you want to it. |
22 | 25 |
|
23 |
| -Some functions to remember are: |
| 26 | +Important functions to use when coding the pause menu: |
| 27 | +- `close();` - Closes the pause menu, resumes gameplay. |
| 28 | +- `FlxG.switchState(new PlayState());` - Reloads the state, restarts the song. |
24 | 29 |
|
25 |
| -`close();` - Closes the pause menu, resumes gameplay |
26 |
| -`FlxG.switchState(new PlayState());` - Reloads the state, restarts the song |
| 30 | +### Game Over Scripts |
| 31 | +Game over scripts work the same as Pause Scripts, though presents some differences. |
| 32 | +This is how you load one: |
| 33 | +```hx |
| 34 | +GameOverSubstate.script = "data/scripts/gameover" |
| 35 | +``` |
| 36 | +This code points to the script that can be found in ``./data/scripts/`` and is called ``gameover.hx``. |
| 37 | + |
| 38 | +Here's an example of playing a video when the player dies: |
| 39 | +```hx |
| 40 | +function create(event) { |
| 41 | + event.cancel(); // cancels out initializing characters and stuff |
| 42 | +
|
| 43 | + deathVideo = new FlxVideo(); |
| 44 | + deathVideo.onEndReached.add(deathVideo.dispose); |
| 45 | + var path = Paths.file("videos/death.mp4"); |
| 46 | + deathVideo.load(Assets.getPath(path)); |
| 47 | + deathVideo.play(); |
| 48 | +} |
| 49 | +``` |
27 | 50 |
|
28 |
| -## Game Over |
29 |
| -idk ive never used the game over script thing oops |
| 51 | +``create``'s event has even more parameters for changing SFX and other stuff. Check for <a href="./All of the script calls.md">All of the script calls</a>, and for calls other than ``create``. |
0 commit comments