Skip to content

Commit 2b70e84

Browse files
authored
also add showing a popup on game launch section
1 parent dcee9a2 commit 2b70e84

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

tutorials/popup.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,20 @@ class $modify(MenuLayer) {
128128
};
129129
```
130130
This will make the popup show correctly by adding it as a child to the new `MenuLayer` instead of the previous scene.
131+
### Showing a popup on game launch
132+
A common scenario is wanting to show a popup on game launch. Doing this through hooking `MenuLayer` would require custom tracking of whether the popup has been shown and also implementing the workarounds in section _Fixing keyboard input_. For this reason, Geode provides an event that handles most of this for you.
133+
```cpp
134+
$on_game(Loaded) {
135+
auto alert = FLAlertLayer::create(
136+
"Title",
137+
"Hi mom!",
138+
"OK"
139+
);
140+
alert->show();
141+
}
142+
```
131143
### Fixing keyboard input
132-
If you use the example above, you will find that keyboard input still goes to the main layer instead of the popup. For `MenuLayer` specifically this can be solved by delaying the addition by a single frame:
144+
If you use the generic example from the main part of section _Popup not showing up_, you will find that keyboard input still goes to the main layer instead of the popup. For `MenuLayer` specifically this can be solved by delaying the addition by a single frame:
133145
```cpp
134146
class $modify(MenuLayer) {
135147
bool init() {

0 commit comments

Comments
 (0)