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: tutorials/popup.md
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,8 +128,20 @@ class $modify(MenuLayer) {
128
128
};
129
129
```
130
130
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
+
```
131
143
### 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:
0 commit comments