Skip to content

Commit 88abeae

Browse files
committed
sgfdsfdsfdf
1 parent 3634526 commit 88abeae

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed
Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
11
# Pause and Game Over Scripts
22

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)*.
56
```hx
67
PauseSubState.script = 'data/scripts/pause';
78
```
9+
This code points to the script that can be found in ``./data/scripts/`` and is called ``pause.hx``.
810

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:
1012
```hx
11-
function create(e){
12-
e.cancel();
13+
function create(event){
14+
event.cancel();
1315
1416
camera = pauseCam = new FlxCamera();
1517
pauseCam.bgColor = FlxColor.TRANSPARENT;
1618
FlxG.cameras.add(pauseCam, false);
1719
18-
// your code goes below this line
20+
// your code here
1921
}
2022
```
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.
2225

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.
2429

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+
```
2750

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

Comments
 (0)