Skip to content

Commit 84dacc9

Browse files
committed
document traces and accessing them
1 parent 6c188aa commit 84dacc9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

assets/content/cookbook/Expert/-06.MiscellaneousCodingTricks.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ This article will cover a handful of miscellaneous coding tricks that you could
66

77
Most of these are recommeded to be used with [Modules](01.ScriptedModules.md), so it is recommended that you familiarize yourself with them beforehand.
88

9+
## Accessing the game's traces
10+
11+
By opening the command prompt and navigating to the folder the Funkin' application is with the `cd path/to/move/to` command, you can run `./Funkin` on Windows, macOS and Linux to open the game on the console. This has the benefits of being able to see what the game prints on the console, which is useful for debugging. On top of that, you can even print on the console yourself by using the `trace()` function, like in the following example.
12+
13+
```haxe
14+
// ...
15+
16+
public override function onCreate(event:ScriptEvent)
17+
{
18+
super.onCreate(event);
19+
20+
trace("Created!");
21+
}
22+
23+
// ...
24+
```
25+
26+
The traces, both by the source code and by the scripts, redirect to the file it was traced from. To separate the two, traces done by scripts are made distinct by encompassing the path in `hscriptClass()`.
27+
928
## Activating something only on game launch
1029

1130
As of 0.8.0, the `onCreate` function on Modules gets dispatched on hot-reloading, alongside getting dispatched after everything in the game was initialized. This could potentially break a couple of things that the programmer wanted to only be activated once, on game launch. Luckily, Flixel provides a signal for this - `FlxG.signals.postGameStart`, which gets dispatched after everything in the game's initialization state gets created.

0 commit comments

Comments
 (0)