-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
2364 lines (2301 loc) · 116 KB
/
data.js
File metadata and controls
2364 lines (2301 loc) · 116 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* All documentation content + navigation tree. One source of truth. */
/* Each page has { id, title, category, sections: [{ id, title, kind, ... }] } */
/* Kinds: 'prose' | 'api' | 'faq' | 'colors' | 'easings' */
const NAV = [
{
title: "Overview",
items: [
{ id: "introduction", label: "Introduction" },
{ id: "getting-started", label: "Getting Started" },
],
},
{
title: "API Reference",
items: [
{ id: "event-callbacks", label: "Event Callbacks" },
{ id: "se-sprites", label: "Sprite Functions" },
{ id: "se-animation", label: "Animation Functions" },
{ id: "se-tween", label: "Tween Functions" },
{ id: "se-reflection", label: "Reflection API" },
{ id: "se-sound", label: "Sound Functions" },
{ id: "se-camera", label: "Camera Functions" },
{ id: "se-text", label: "Text Functions" },
{ id: "se-input", label: "Input Functions" },
{ id: "se-score", label: "Score & Health" },
{ id: "se-character", label: "Character Functions" },
{ id: "se-playstate", label: "PlayState Functions" },
{ id: "se-timer", label: "Timer Functions" },
{ id: "se-shader", label: "Shader Functions" },
{ id: "se-script", label: "Script Management" },
{ id: "se-hscript", label: "HScript Integration" },
{ id: "se-substate", label: "Scripted State/Substate" },
{ id: "se-save", label: "Save Data" },
{ id: "se-file", label: "File I/O" },
{ id: "se-precache", label: "Precaching" },
{ id: "se-mobile", label: "Mobile Functions" },
{ id: "se-discord", label: "Discord RPC" },
{ id: "se-deprecated", label: "Deprecated Functions" },
],
},
{
title: "Reference",
items: [
{ id: "se-variables", label: "Built-in Variables" },
{ id: "easings", label: "Easing Names" },
{ id: "colors", label: "Color Format" },
],
},
{
title: "Guides",
items: [
{ id: "examples", label: "Examples" },
{ id: "faq", label: "FAQ" },
],
},
];
/* shortcut helpers */
const P = (id, title, body) => ({ id, title, kind: "prose", body });
const API = (cfg) => ({ ...cfg, kind: "api" });
const PAGES = {
/* ---------------- Introduction ---------------- */
"introduction": {
title: "Introduction",
category: "Overview",
hero: true,
sections: [
{
id: "what",
title: "What is Shadow Engine?",
kind: "prose",
body: `Shadow Engine is a <strong>Friday Night Funkin'-style rhythm-game engine</strong> with a built-in Lua scripting layer. Scripts can create sprites, tween their properties, read and write engine state via reflection, and hook into the conductor as the song plays.
Scripts live under <code>scripts/</code>, <code>stages/</code>, <code>characters/</code>, and other folders, loaded at runtime.`,
},
],
},
/* ---------------- Installation ---------------- */
/* ---------------- Getting Started ---------------- */
"getting-started": {
title: "Getting Started",
category: "Overview",
sections: [
{
id: "anatomy",
title: "Anatomy of a script",
kind: "prose",
body: `A Shadow Engine script is a plain Lua file. Define any of the <a href="#" data-go="event-callbacks">event callbacks</a> at top level and they will be invoked by the engine. Inside those callbacks, create and manipulate sprites and tweens using flat global functions.`,
code: {
lang: "lua",
filename: "mods/scripts/intro.lua",
source: `-- 1. create a sprite with the tag 'logo'
function onCreate()
makeLuaSprite('logo', 'myimages/logo', 200, 50)
addLuaSprite('logo')
end
-- 2. animate it on every beat
function onBeatHit(beat)
doTweenAngle('spin', 'logo', 360, 0.4, 'quadOut')
end
-- 3. clean up when the state tears down
function onDestroy()
print("bye!")
end`,
highlight: [1, 6, 12],
},
},
{
id: "lifecycle",
title: "Lifecycle",
kind: "prose",
body: `Scripts share their lifecycle with <code>MusicBeatState</code>:
<ol>
<li><strong>Discovery</strong> — every <code>.lua</code> under <code>mods/scripts/</code> is registered when the state is created.</li>
<li><strong>onCreate()</strong> — fired right after the state's <code>create()</code> returns.</li>
<li><strong>Per-frame & conductor callbacks</strong> — <code>onUpdate</code>, <code>onBeatHit</code>, <code>onStepHit</code>, <code>onSectionHit</code>.</li>
<li><strong>onDestroy()</strong> — fired when the state tears down.</li>
</ol>`,
},
{
id: "next",
title: "What to read next",
kind: "prose",
body: `<ul>
<li><a href="#" data-go="se-sprites">Sprite Functions</a> — every drawing function</li>
<li><a href="#" data-go="se-tween">Tween Functions</a> — every tween function</li>
<li><a href="#" data-go="se-reflection">Reflection API</a> — read & write engine state</li>
<li><a href="#" data-go="examples">Full examples</a> — beat-reactive scenes and effects</li>
</ul>`,
},
],
},
/* ---------------- Event Callbacks ---------------- */
"event-callbacks": {
title: "Event Callbacks",
category: "API Reference",
sections: [
{
id: "intro",
title: "Overview",
kind: "prose",
body: `The engine drives scripts through lifecycle callbacks. <code>MusicBeatState</code> broadcasts each one to every registered script that defines it; if a script omits a callback, nothing happens.
<b>Core callbacks:</b>
<table class="tbl">
<thead><tr><th>Callback</th><th>Parameters</th><th>Description</th></tr></thead>
<tbody>
<tr><td>onCreate()</td><td>—</td><td>Set up sprites, tweens and state here.</td></tr>
<tr><td>onCreatePost()</td><td>—</td><td>Fires after create() is fully done.</td></tr>
<tr><td>onNew()</td><td>—</td><td>Fires in constructor before create.</td></tr>
<tr><td>onNewPost()</td><td>—</td><td>Fires after constructor.</td></tr>
<tr><td>onUpdate(elapsed)</td><td>Float</td><td>Per-frame logic.</td></tr>
<tr><td>onUpdatePost(elapsed)</td><td>Float</td><td>Per-frame logic after super.update.</td></tr>
<tr><td>onStepHit()</td><td>—</td><td>Every quarter beat.</td></tr>
<tr><td>onBeatHit(beat)</td><td>Int</td><td>Every beat.</td></tr>
<tr><td>onSectionHit()</td><td>—</td><td>Every measure.</td></tr>
<tr><td>onTweenCompleted(tag)</td><td>String</td><td>Fires when a tween finishes.</td></tr>
<tr><td>onTimerCompleted(tag, loops, left)</td><td>String, Int, Int</td><td>Fires when a timer completes.</td></tr>
<tr><td>onSoundFinished(tag)</td><td>String</td><td>Fires when a tagged sound finishes.</td></tr>
<tr><td>onEvent(name, v1, v2)</td><td>String, String, String</td><td>Fires on chart events.</td></tr>
<tr><td>onCountdownStarted()</td><td>—</td><td>Fires when countdown begins.</td></tr>
<tr><td>onCountdownEnded()</td><td>—</td><td>Fires when countdown ends.</td></tr>
<tr><td>onEndSong()</td><td>—</td><td>Can return Function_Stop to prevent ending.</td></tr>
<tr><td>onNoteHit(noteData)</td><td>Int</td><td>Player hits a note.</td></tr>
<tr><td>onNoteMiss(dir)</td><td>Int</td><td>Player misses.</td></tr>
<tr><td>onGhostTap(dir)</td><td>Int</td><td>Player presses nothing.</td></tr>
<tr><td>onGameOver()</td><td>—</td><td>Fires on death.</td></tr>
<tr><td>onOpenSubState()</td><td>—</td><td>Fires when a substate opens.</td></tr>
<tr><td>onCloseSubState()</td><td>—</td><td>Fires when a substate closes.</td></tr>
<tr><td>goodNoteHit(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires when player hits a note (after hit)</td></tr>
<tr><td>opponentNoteHit(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires when opponent hits a note</td></tr>
<tr><td>goodNoteHitPre(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires before player note hit (can cancel)</td></tr>
<tr><td>opponentNoteHitPre(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires before opponent note hit (can cancel)</td></tr>
<tr><td>onSongStart()</td><td>—</td><td>Fires when song begins playing</td></tr>
<tr><td>onStartCountdown()</td><td>—</td><td>Fires when countdown is about to start</td></tr>
<tr><td>onCountdownTick(tick)</td><td>Int</td><td>Fires on each countdown tick</td></tr>
<tr><td>onPause()</td><td>—</td><td>Fires when game is paused</td></tr>
<tr><td>onGameOverStart()</td><td>—</td><td>Fires on game over start</td></tr>
<tr><td>onGameOverConfirm()</td><td>—</td><td>Fires on game over confirm (retry/exit)</td></tr>
<tr><td>onSpawnNote(noteData, note)</td><td>Int, Note</td><td>Fires when a note spawns</td></tr>
<tr><td>onKeyPress(dir)</td><td>Int</td><td>Fires on gameplay key press</td></tr>
<tr><td>onKeyRelease(dir)</td><td>Int</td><td>Fires on gameplay key release</td></tr>
<tr><td>onRecalculateRating()</td><td>—</td><td>Fires when score rating is recalculated</td></tr>
<tr><td>onDestroy()</td><td>—</td><td>Final cleanup.</td></tr>
</tbody>
</table>`,
},
{
id: "callbacks",
title: "Callback list",
kind: "prose",
body: `<table class="tbl">
<thead><tr><th>Callback</th><th>Parameters</th><th>Description</th></tr></thead>
<tbody>
<tr><td>onCreate()</td><td>—</td><td>Set up sprites, tweens and state here.</td></tr>
<tr><td>onCreatePost()</td><td>—</td><td>Fires after create() is fully done.</td></tr>
<tr><td>onNew()</td><td>—</td><td>Fires in constructor before create.</td></tr>
<tr><td>onNewPost()</td><td>—</td><td>Fires after constructor.</td></tr>
<tr><td>onUpdate(elapsed)</td><td>Float</td><td>Per-frame logic.</td></tr>
<tr><td>onUpdatePost(elapsed)</td><td>Float</td><td>Per-frame logic after super.update.</td></tr>
<tr><td>onStepHit()</td><td>—</td><td>Every quarter beat.</td></tr>
<tr><td>onBeatHit(beat)</td><td>Int</td><td>Every beat.</td></tr>
<tr><td>onSectionHit()</td><td>—</td><td>Every measure.</td></tr>
<tr><td>onTweenCompleted(tag)</td><td>String</td><td>Fires when a tween finishes.</td></tr>
<tr><td>onTimerCompleted(tag, loops, left)</td><td>String, Int, Int</td><td>Fires when a timer completes.</td></tr>
<tr><td>onSoundFinished(tag)</td><td>String</td><td>Fires when a tagged sound finishes.</td></tr>
<tr><td>onEvent(name, v1, v2)</td><td>String, String, String</td><td>Fires on chart events.</td></tr>
<tr><td>onCountdownStarted()</td><td>—</td><td>Fires when countdown begins.</td></tr>
<tr><td>onCountdownEnded()</td><td>—</td><td>Fires when countdown ends.</td></tr>
<tr><td>onEndSong()</td><td>—</td><td>Can return Function_Stop to prevent ending.</td></tr>
<tr><td>onNoteHit(noteData)</td><td>Int</td><td>Player hits a note.</td></tr>
<tr><td>onNoteMiss(dir)</td><td>Int</td><td>Player misses.</td></tr>
<tr><td>onGhostTap(dir)</td><td>Int</td><td>Player presses nothing.</td></tr>
<tr><td>onGameOver()</td><td>—</td><td>Fires on death.</td></tr>
<tr><td>onOpenSubState()</td><td>—</td><td>Fires when a substate opens.</td></tr>
<tr><td>onCloseSubState()</td><td>—</td><td>Fires when a substate closes.</td></tr>
<tr><td>goodNoteHit(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires when player hits a note (after hit)</td></tr>
<tr><td>opponentNoteHit(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires when opponent hits a note</td></tr>
<tr><td>goodNoteHitPre(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires before player note hit (can cancel)</td></tr>
<tr><td>opponentNoteHitPre(noteData, note, sustain)</td><td>Int, Note, Bool</td><td>Fires before opponent note hit (can cancel)</td></tr>
<tr><td>onSongStart()</td><td>—</td><td>Fires when song begins playing</td></tr>
<tr><td>onStartCountdown()</td><td>—</td><td>Fires when countdown is about to start</td></tr>
<tr><td>onCountdownTick(tick)</td><td>Int</td><td>Fires on each countdown tick</td></tr>
<tr><td>onPause()</td><td>—</td><td>Fires when game is paused</td></tr>
<tr><td>onGameOverStart()</td><td>—</td><td>Fires on game over start</td></tr>
<tr><td>onGameOverConfirm()</td><td>—</td><td>Fires on game over confirm (retry/exit)</td></tr>
<tr><td>onSpawnNote(noteData, note)</td><td>Int, Note</td><td>Fires when a note spawns</td></tr>
<tr><td>onKeyPress(dir)</td><td>Int</td><td>Fires on gameplay key press</td></tr>
<tr><td>onKeyRelease(dir)</td><td>Int</td><td>Fires on gameplay key release</td></tr>
<tr><td>onRecalculateRating()</td><td>—</td><td>Fires when score rating is recalculated</td></tr>
<tr><td>onDestroy()</td><td>—</td><td>Final cleanup.</td></tr>
</tbody>
</table>`,
code: {
lang: "lua",
filename: "callbacks.lua",
source: `function onCreate()
print("script loaded")
makeLuaSprite('box')
makeGraphic('box', 200, 50, 'FF6699')
addLuaSprite('box')
end
function onBeatHit(beat)
print("BEAT " .. beat)
end
function onDestroy()
print("script unloaded")
end`,
},
},
],
},
/* ---------------- se-sprites ---------------- */
"se-sprites": {
title: "Sprite Functions",
category: "API Reference",
subtitle: "Functions to create, configure, and destroy drawable objects. Every sprite is identified by a string <code>tag</code> that you choose at creation time.",
sections: [
{
id: "creation",
title: "Creation & Addition",
kind: "prose",
body: "These functions create sprites and add them to the display list. Sprites are not visible until <code>addLuaSprite</code> is called.",
},
API({
id: "makeLuaSprite",
signature: "makeLuaSprite(tag, ?image, ?x, ?y)",
params: [["tag","String","Unique sprite identifier"],["image","String","Image path (no extension), resolved through <code>Paths.image</code>","optional"],["x","Float","Initial X position","default 0"],["y","Float","Initial Y position","default 0"]],
returns: "Void",
description: "Creates a static sprite. If <code>image</code> is omitted or nil, creates an empty sprite (use <code>makeGraphic</code> to give it a rectangle).",
code: { lang: "lua", source: `makeLuaSprite('logo', 'menus/logo', 100, 50)
addLuaSprite('logo')` },
}),
API({
id: "makeAnimatedLuaSprite",
signature: "makeAnimatedLuaSprite(tag, ?image, ?x, ?y, ?spriteType, ?swfMode, ?cacheOnLoad)",
params: [["tag","String","Unique sprite identifier"],["image","String","Image path (no extension)","optional"],["x","Float","X position","default 0"],["y","Float","Y position","default 0"],["spriteType","String","<code>'sparrow'</code>, <code>'packer'</code>, or <code>'aseprite'</code>","default 'sparrow'"],["swfMode","Bool","SWF-style animation mode","default false"],["cacheOnLoad","Bool","Cache frames on load","default false"]],
returns: "Void",
description: "Creates an animated sprite from a sparrow/packer/aseprite atlas. Use <code>addAnimationByPrefix</code> etc. to define animations.",
code: { lang: "lua", source: `makeAnimatedLuaSprite('bf', 'characters/bf', 400, 300, 'sparrow')
addLuaSprite('bf')
addAnimationByPrefix('bf', 'idle', 'BF idle dance', 24, true)` },
}),
API({
id: "makeGraphic",
signature: "makeGraphic(obj, ?width, ?height, ?color)",
params: [["obj","String","Sprite tag"],["width","Int","Rectangle width","default 100"],["height","Int","Rectangle height","default 100"],["color","String","Fill color hex (<code>'RRGGBB'</code>)","default 'FFFFFF'"]],
returns: "Void",
description: "Replaces the sprite's graphic with a solid-color rectangle. Useful for overlay boxes, bars, and placeholders.",
code: { lang: "lua", source: `makeLuaSprite('box')
makeGraphic('box', 200, 80, 'FF6699')
addLuaSprite('box')` },
}),
API({
id: "addLuaSprite",
signature: "addLuaSprite(tag, ?front)",
params: [["tag","String","Sprite tag to add to the display list"],["front","Bool","If true, adds to the front layer","default false"]],
returns: "Void",
description: "Adds a previously-created sprite to the state's draw list. Sprites are invisible until added.",
code: { lang: "lua", source: `makeLuaSprite('bg', 'stages/field', 0, 0)
addLuaSprite('bg')` },
}),
API({
id: "removeLuaSprite",
signature: "removeLuaSprite(tag, ?destroy)",
params: [["tag","String","Sprite tag to remove"],["destroy","Bool","If true, also destroys the sprite","default false"]],
returns: "Void",
description: "Removes a sprite from the display list. Optionally destroys it.",
code: { lang: "lua", source: `removeLuaSprite('old_bg', true)` },
}),
API({
id: "luaSpriteExists",
signature: "luaSpriteExists(tag)",
params: [["tag","String","Sprite tag to check"]],
returns: "Bool",
description: "Returns <code>true</code> if a sprite with the given tag has been created (regardless of whether it was added to the display list).",
code: { lang: "lua", source: `if luaSpriteExists('logo') then
print('logo exists')
end` },
}),
{
id: "transforms",
title: "Position & Transform",
kind: "prose",
body: "Functions that move, scale, and center sprites.",
},
API({
id: "setObjectCamera",
signature: "setObjectCamera(obj, camera)",
params: [["obj","String","Sprite tag"],["camera","String","Camera name: <code>'game'</code>, <code>'hud'</code>, <code>'other'</code>"]],
returns: "Void",
description: "Assigns the sprite to a camera. Sprites default to the game camera.",
code: { lang: "lua", source: `setObjectCamera('score_display', 'hud')` },
}),
API({
id: "setBlendMode",
signature: "setBlendMode(obj, blend)",
params: [["obj","String","Sprite tag"],["blend","String","Blend mode: <code>'add'</code>, <code>'multiply'</code>, <code>'screen'</code>, etc."]],
returns: "Void",
description: "Sets the sprite's blend mode for compositing.",
code: { lang: "lua", source: `setBlendMode('glow_overlay', 'add')` },
}),
API({
id: "setScrollFactor",
signature: "setScrollFactor(obj, scrollX, scrollY)",
params: [["obj","String","Sprite tag"],["scrollX","Float","Horizontal scroll factor","default 1"],["scrollY","Float","Vertical scroll factor","default 1"]],
returns: "Void",
description: "Sets how strongly the sprite follows camera movement. <code>0</code> = screen-locked (HUD), <code>1</code> = full parallax.",
code: { lang: "lua", source: `setScrollFactor('bg_sky', 0.1, 0.1)
setScrollFactor('hud_bar', 0, 0)` },
}),
API({
id: "screenCenter",
signature: "screenCenter(obj, ?pos)",
params: [["obj","String","Sprite tag"],["pos","String","Axis: <code>'x'</code>, <code>'y'</code>, or omitted for both","optional"]],
returns: "Void",
description: "Centers the sprite on screen. Without <code>pos</code>, centers on both axes.",
code: { lang: "lua", source: `screenCenter('logo') -- both axes
screenCenter('logo', 'x') -- horizontal only` },
}),
API({
id: "setGraphicSize",
signature: "setGraphicSize(obj, x, ?y, ?updateHitbox)",
params: [["obj","String","Sprite tag"],["x","Int","Target width in pixels"],["y","Int","Target height (omitted = square)","optional"],["updateHitbox","Bool","Recalculate hitbox after resize","default false"]],
returns: "Void",
description: "Sets the sprite's pixel dimensions directly.",
code: { lang: "lua", source: `setGraphicSize('logo', 320, 240, true)` },
}),
API({
id: "scaleObject",
signature: "scaleObject(obj, x, y, ?updateHitbox)",
params: [["obj","String","Sprite tag"],["x","Float","Horizontal scale multiplier"],["y","Float","Vertical scale multiplier"],["updateHitbox","Bool","Recalculate hitbox after scaling","default false"]],
returns: "Void",
description: "Scales the sprite by a multiplier. <code>1.0</code> = original size, <code>2.0</code> = double.",
code: { lang: "lua", source: `scaleObject('logo', 1.5, 1.5, true)` },
}),
API({
id: "updateHitbox",
signature: "updateHitbox(obj)",
params: [["obj","String","Sprite tag"]],
returns: "Void",
description: "Recalculates the sprite's hitbox to match its current scale/graphic size.",
code: { lang: "lua", source: `scaleObject('logo', 2.0, 2.0)
updateHitbox('logo')` },
}),
API({
id: "updateHitboxFromGroup",
signature: "updateHitboxFromGroup(group, index)",
params: [["group","String","Group tag"],["index","Int","Member index within the group"]],
returns: "Void",
description: "Updates the hitbox of a specific member within a sprite group.",
code: { lang: "lua", source: `updateHitboxFromGroup('note_splashes', 3)` },
}),
{
id: "ordering",
title: "Draw Order",
kind: "prose",
body: "Control the Z-order of sprites within their display list.",
},
API({
id: "setObjectOrder",
signature: "setObjectOrder(obj, position, ?group)",
params: [["obj","String","Sprite tag"],["position","Int","Target draw index"],["group","String","Group to reorder within","optional"]],
returns: "Void",
description: "Moves the sprite to a specific draw order index. Lower indices are drawn first (behind).",
code: { lang: "lua", source: `setObjectOrder('logo', 0) -- draw first (back)
setObjectOrder('player', 10) -- draw later (front)` },
}),
API({
id: "getObjectOrder",
signature: "getObjectOrder(obj)",
params: [["obj","String","Sprite tag"]],
returns: "Int",
description: "Returns the sprite's current draw order index.",
code: { lang: "lua", source: `local order = getObjectOrder('logo')` },
}),
API({
id: "objectsOverlap",
signature: "objectsOverlap(obj1, obj2)",
params: [["obj1","String","First sprite tag"],["obj2","String","Second sprite tag"]],
returns: "Bool",
description: "Returns <code>true</code> if the two sprites' hitboxes overlap.",
code: { lang: "lua", source: `if objectsOverlap('cursor', 'button') then
print('hovering!')
end` },
}),
{
id: "queries",
title: "Position Queries",
kind: "prose",
body: "Read positional values from sprites.",
},
API({
id: "getMidpointX",
signature: "getMidpointX(variable)",
params: [["variable","String","Sprite tag"]],
returns: "Float",
description: "Returns the X coordinate of the sprite's midpoint (center of the sprite's bounding box in world space).",
code: { lang: "lua", source: `local mx = getMidpointX('player')` },
}),
API({
id: "getMidpointY",
signature: "getMidpointY(variable)",
params: [["variable","String","Sprite tag"]],
returns: "Float",
description: "Returns the Y coordinate of the sprite's midpoint.",
code: { lang: "lua", source: `local my = getMidpointY('player')` },
}),
API({
id: "getGraphicMidpointX",
signature: "getGraphicMidpointX(variable)",
params: [["variable","String","Sprite tag"]],
returns: "Float",
description: "Returns the X coordinate of the graphic's midpoint (center of the texture, ignoring offsets).",
code: { lang: "lua", source: `local gmx = getGraphicMidpointX('player')` },
}),
API({
id: "getGraphicMidpointY",
signature: "getGraphicMidpointY(variable)",
params: [["variable","String","Sprite tag"]],
returns: "Float",
description: "Returns the Y coordinate of the graphic's midpoint.",
code: { lang: "lua", source: `local gmy = getGraphicMidpointY('player')` },
}),
API({
id: "getScreenPositionX",
signature: "getScreenPositionX(variable, ?camera)",
params: [["variable","String","Sprite tag"],["camera","String","Camera name (<code>'game'</code>/<code>'hud'</code>)","optional"]],
returns: "Float",
description: "Returns the sprite's X position in screen coordinates for the given camera.",
code: { lang: "lua", source: `local sx = getScreenPositionX('hud_element', 'hud')` },
}),
API({
id: "getScreenPositionY",
signature: "getScreenPositionY(variable, ?camera)",
params: [["variable","String","Sprite tag"],["camera","String","Camera name","optional"]],
returns: "Float",
description: "Returns the sprite's Y position in screen coordinates for the given camera.",
code: { lang: "lua", source: `local sy = getScreenPositionY('hud_element', 'hud')` },
}),
{
id: "pixel",
title: "Pixel & Graphic Loading",
kind: "prose",
body: "Read pixel data from sprites and swap their graphics at runtime.",
},
API({
id: "getPixelColor",
signature: "getPixelColor(obj, x, y)",
params: [["obj","String","Sprite tag"],["x","Int","X coordinate within the sprite's bitmap"],["y","Int","Y coordinate within the sprite's bitmap"]],
returns: "Int",
description: "Returns the color of a specific pixel on the sprite's bitmap as an ARGB integer.",
code: { lang: "lua", source: `local col = getPixelColor('logo', 50, 30)` },
}),
API({
id: "loadGraphic",
signature: "loadGraphic(variable, image, ?gridX, ?gridY)",
params: [["variable","String","Sprite tag"],["image","String","Image path (no extension)"],["gridX","Int","Frame width for sprite sheet grid","default 0"],["gridY","Int","Frame height for sprite sheet grid","default 0"]],
returns: "Void",
description: "Loads a new image onto an existing sprite, optionally splitting it into a grid of frames.",
code: { lang: "lua", source: `loadGraphic('player', 'characters/bf_dance', 150, 150)` },
}),
API({
id: "loadFrames",
signature: "loadFrames(variable, image, ?spriteType)",
params: [["variable","String","Sprite tag"],["image","String","Image path (no extension)"],["spriteType","String","<code>'sparrow'</code>, <code>'packer'</code>, or <code>'aseprite'</code>","default 'sparrow'"]],
returns: "Void",
description: "Loads animated frames onto an existing sprite from an atlas.",
code: { lang: "lua", source: `loadFrames('bf', 'characters/bf')` },
}),
{
id: "utility",
title: "Utility Functions",
kind: "prose",
body: `<table class="tbl">
<thead><tr><th>Function</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>FlxColor(colorString)</code></td><td>Creates a FlxColor from string (alias for getColorFromString)</td></tr>
<tr><td><code>getColorFromName(colorString)</code></td><td>Creates color from string name</td></tr>
<tr><td><code>getColorFromString(colorString)</code></td><td>Creates color from string</td></tr>
<tr><td><code>getColorFromHex(hex)</code></td><td>Creates color from hex string (auto-prepends #)</td></tr>
<tr><td><code>stringStartsWith(str, prefix)</code></td><td>String starts with check</td></tr>
<tr><td><code>stringEndsWith(str, suffix)</code></td><td>String ends with check</td></tr>
<tr><td><code>stringSplit(str, delimiter)</code></td><td>Splits string into table</td></tr>
<tr><td><code>stringTrim(str)</code></td><td>Trims whitespace</td></tr>
<tr><td><code>getRandomInt(min, max, ?exclude)</code></td><td>Random integer</td></tr>
<tr><td><code>getRandomFloat(min, max, ?exclude)</code></td><td>Random float</td></tr>
<tr><td><code>getRandomBool()</code></td><td>Random boolean</td></tr>
<tr><td><code>debugPrint(text, ?color)</code></td><td>Prints debug text to screen</td></tr>
</tbody>
</table>`,
},
],
},
/* ---------------- se-animation ---------------- */
"se-animation": {
title: "Animation Functions",
category: "API Reference",
subtitle: "Define and play animations on animated sprites. Animations are identified by a <code>name</code> string you choose when adding them.",
sections: [
{
id: "anim-create",
title: "Adding Animations",
kind: "prose",
body: "These functions register animations on animated sprites created with <code>makeAnimatedLuaSprite</code>.",
},
API({
id: "addAnimationByPrefix",
signature: "addAnimationByPrefix(obj, name, prefix, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name (used with <code>playAnim</code>)"],["prefix","String","Frame prefix in the sparrow/packer XML"],["framerate","Int","Frames per second","default 24"],["loop","Bool","Whether the animation loops","default true"]],
returns: "Void",
description: "Adds an animation by matching frame names that start with <code>prefix</code>. The standard sparrow-style method.",
code: { lang: "lua", source: `addAnimationByPrefix('bf', 'idle', 'BF idle dance', 24, true)
addAnimationByPrefix('bf', 'singUP', 'BF notes up', 24, false)` },
}),
API({
id: "addAnimation",
signature: "addAnimation(obj, name, frames, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name"],["frames","Table","Array of frame indices, e.g. <code>{0,1,2,3}</code>"],["framerate","Int","Frames per second","default 24"],["loop","Bool","Whether the animation loops","default true"]],
returns: "Void",
description: "Adds an animation by specifying exact frame indices.",
code: { lang: "lua", source: `addAnimation('bf', 'blink', {0, 1}, 4, false)` },
}),
API({
id: "addAnimationByIndices",
signature: "addAnimationByIndices(obj, name, prefix, indices, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name"],["prefix","String","Frame prefix"],["indices","String","Comma-separated frame indices, e.g. <code>'0,2,4,6'</code>"],["framerate","Int","FPS","default 24"],["loop","Bool","Looping","default true"]],
returns: "Void",
description: "Adds an animation by prefix + comma-separated index string.",
code: { lang: "lua", source: `addAnimationByIndices('bf', 'dodge', 'BF dodge', '0,3,5', 12, false)` },
}),
API({
id: "addAnimationBySymbol",
signature: "addAnimationBySymbol(obj, name, symbol, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name"],["symbol","String","Symbol name from flixel animate atlas"],["framerate","Int","FPS","default 24"],["loop","Bool","Looping","default true"]],
returns: "Void",
description: "Adds an animation by flixel animate symbol (for animate-atlas sprites).",
code: { lang: "lua", source: `addAnimationBySymbol('character', 'walk', 'walk_cycle', 12, true)` },
}),
API({
id: "addAnimationBySymbolIndices",
signature: "addAnimationBySymbolIndices(obj, name, symbol, indices, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name"],["symbol","String","Symbol name"],["indices","String","Comma-separated frame indices"],["framerate","Int","FPS","default 24"],["loop","Bool","Looping","default true"]],
returns: "Void",
description: "Adds an animation by symbol + specific frame indices.",
code: { lang: "lua", source: `addAnimationBySymbolIndices('character', 'jump', 'jump_anim', '0,2,5', 12, false)` },
}),
API({
id: "addAnimationByFrameLabel",
signature: "addAnimationByFrameLabel(obj, name, label, ?framerate, ?loop)",
params: [["obj","String","Sprite tag"],["name","String","Animation name"],["label","String","Frame label from the atlas"],["framerate","Int","FPS","default 24"],["loop","Bool","Looping","default true"]],
returns: "Void",
description: "Adds an animation by frame label (for labeled atlas frames).",
code: { lang: "lua", source: `addAnimationByFrameLabel('character', 'taunt', 'taunt_start', 12, false)` },
}),
{
id: "playback",
title: "Playback & Offsets",
kind: "prose",
body: "Control animation playback and add positional offsets.",
},
API({
id: "playAnim",
signature: "playAnim(obj, name, ?forced, ?reverse, ?startFrame)",
params: [["obj","String","Sprite tag"],["name","String","Animation name to play"],["forced","Bool","Force restart even if already playing","default false"],["reverse","Bool","Play in reverse","default false"],["startFrame","Int","Frame index to start from","default 0"]],
returns: "Void",
description: "Plays a registered animation. If <code>forced</code> is false and the animation is already playing, it won't restart.",
code: { lang: "lua", source: `playAnim('bf', 'singUP', true)` },
}),
API({
id: "addOffset",
signature: "addOffset(obj, anim, x, y)",
params: [["obj","String","Sprite tag"],["anim","String","Animation name"],["x","Float","Horizontal offset in pixels"],["y","Float","Vertical offset in pixels"]],
returns: "Void",
description: "Adds a positional offset to an animation. Useful for centering or adjusting specific animations without affecting the sprite's main position.",
code: { lang: "lua", source: `addOffset('bf', 'singLEFT', -20, 0)` },
}),
],
},
/* ---------------- se-tween ---------------- */
"se-tween": {
title: "Tween Functions",
category: "API Reference",
subtitle: "Animate sprite properties over time. Each tween is keyed by a string <code>tag</code> — starting a new tween with an existing tag cancels the previous one automatically.",
sections: [
{
id: "tween-gen",
title: "Generic & Convenience Tweens",
kind: "prose",
body: "Tween any numeric property or use the convenience wrappers for common properties.",
},
API({
id: "startTween",
signature: "startTween(tag, vars, values, duration, ?options)",
params: [["tag","String","Tween identifier (cancels previous with same tag)"],["vars","String","Sprite tag (or dotted path like <code>'logo.scale'</code>)"],["values","Table","Target values, e.g. <code>{alpha = 0, x = 100}</code>"],["duration","Float","Duration in seconds"],["options","Table","Optional: <code>{ease, type, startDelay, loopDelay, onUpdate, onStart, onComplete}</code>","optional"]],
returns: "Void",
description: "Generic tween for any numeric properties. The <code>options</code> table supports: <code>ease</code> (string), <code>type</code> (FlxTween type constant: PERSIST=1, LOOPING=2, PINGPONG=4, ONESHOT=8), <code>startDelay</code>, <code>loopDelay</code>, <code>onUpdate</code>, <code>onStart</code>, <code>onComplete</code> (functions).",
code: { lang: "lua", source: `startTween('logoFade', 'logo', {alpha = 0}, 1.5, {ease = 'quadOut'})
startTween('spin', 'logo', {angle = 360}, 2.0, {type = 4})` },
}),
API({
id: "doTweenX",
signature: "doTweenX(tag, vars, value, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Sprite tag"],["value","Float","Target X position"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens horizontal position.",
code: { lang: "lua", source: `doTweenX('slide', 'logo', 800, 2.0, 'cubeInOut')` },
}),
API({
id: "doTweenY",
signature: "doTweenY(tag, vars, value, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Sprite tag"],["value","Float","Target Y position"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens vertical position.",
code: { lang: "lua", source: `doTweenY('drop', 'box', 600, 1.0, 'bounceOut')` },
}),
API({
id: "doTweenAngle",
signature: "doTweenAngle(tag, vars, value, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Sprite tag"],["value","Float","Target rotation in degrees"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens rotation angle.",
code: { lang: "lua", source: `doTweenAngle('spin', 'logo', 90, 0.4, 'quadOut')` },
}),
API({
id: "doTweenAlpha",
signature: "doTweenAlpha(tag, vars, value, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Sprite tag"],["value","Float","Target alpha (0–1)"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens transparency.",
code: { lang: "lua", source: `doTweenAlpha('fade', 'box', 0.25, 1.5, 'quadOut')` },
}),
API({
id: "doTweenZoom",
signature: "doTweenZoom(tag, vars, value, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Camera or object tag"],["value","Float","Target zoom level"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the zoom of a camera or sprite.",
code: { lang: "lua", source: `doTweenZoom('camZoom', 'camGame', 1.5, 0.5, 'cubeOut')` },
}),
API({
id: "doTweenColor",
signature: "doTweenColor(tag, vars, targetColor, duration, ease)",
params: [["tag","String","Tween tag"],["vars","String","Sprite tag"],["targetColor","String","Target hex color (<code>'RRGGBB'</code>)"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the sprite's color tint.",
code: { lang: "lua", source: `doTweenColor('recolor', 'box', '00FFAA', 2.5, 'sineInOut')` },
}),
API({
id: "cancelTween",
signature: "cancelTween(tag)",
params: [["tag","String","Tween tag to cancel"]],
returns: "Void",
description: "Cancels an active tween by its tag.",
code: { lang: "lua", source: `cancelTween('spin')` },
}),
{
id: "note-tweens",
title: "Note / Strumline Tweens",
kind: "prose",
body: "Convenience tweens for strumline (note receptor) properties. The <code>note</code> parameter is the strum index (0=left, 1=down, 2=up, 3=right).",
},
API({
id: "noteTweenX",
signature: "noteTweenX(tag, note, value, duration, ease)",
params: [["tag","String","Tween tag"],["note","Int","Strum index (0–3)"],["value","Float","Target X position"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the X position of a strum line.",
code: { lang: "lua", source: `noteTweenX('slideLeft', 0, -100, 0.5, 'quadOut')` },
}),
API({
id: "noteTweenY",
signature: "noteTweenY(tag, note, value, duration, ease)",
params: [["tag","String","Tween tag"],["note","Int","Strum index (0–3)"],["value","Float","Target Y position"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the Y position of a strum line.",
code: { lang: "lua", source: `noteTweenY('raiseUp', 1, -50, 0.3, 'backOut')` },
}),
API({
id: "noteTweenAngle",
signature: "noteTweenAngle(tag, note, value, duration, ease)",
params: [["tag","String","Tween tag"],["note","Int","Strum index (0–3)"],["value","Float","Target rotation in degrees"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the rotation angle of a strum line.",
code: { lang: "lua", source: `noteTweenAngle('spinStrum', 2, 180, 1.0, 'elasticOut')` },
}),
API({
id: "noteTweenAlpha",
signature: "noteTweenAlpha(tag, note, value, duration, ease)",
params: [["tag","String","Tween tag"],["note","Int","Strum index (0–3)"],["value","Float","Target alpha (0–1)"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the alpha of a strum line.",
code: { lang: "lua", source: `noteTweenAlpha('hideStrum', 3, 0, 0.4, 'quadOut')` },
}),
API({
id: "noteTweenDirection",
signature: "noteTweenDirection(tag, note, value, duration, ease)",
params: [["tag","String","Tween tag"],["note","Int","Strum index (0–3)"],["value","Float","Target direction angle"],["duration","Float","Duration in seconds"],["ease","String","Ease name","default 'linear'"]],
returns: "Void",
description: "Tweens the direction angle of a strum line.",
code: { lang: "lua", source: `noteTweenDirection('rotateDir', 1, 90, 0.5, 'sineOut')` },
}),
],
},
/* ---------------- se-text ---------------- */
"se-text": {
title: "Text Functions",
category: "API Reference",
subtitle: "Create, configure, and manage <code>FlxText</code> objects. Text objects are identified by a string <code>tag</code>, just like sprites.",
sections: [
{
id: "text-creation",
title: "Creation & Lifecycle",
kind: "prose",
body: "Create text objects, add/remove them from the display list, and check their existence.",
},
API({
id: "makeLuaText",
signature: "makeLuaText(tag, text, width, x, y)",
params: [["tag","String","Unique text identifier"],["text","String","Text content to display"],["width","Int","Field width in pixels (<code>0</code> = auto-size)"],["x","Float","X position","default 0"],["y","Float","Y position","default 0"]],
returns: "Void",
description: "Creates a text object. Text is not visible until <code>addLuaText</code> is called.",
code: { lang: "lua", source: `makeLuaText('title', 'Hello World!', 0, 100, 50)
addLuaText('title')` },
}),
API({
id: "addLuaText",
signature: "addLuaText(tag)",
params: [["tag","String","Text tag to add to the display list"]],
returns: "Void",
description: "Adds a previously-created text object to the state's draw list.",
code: { lang: "lua", source: `addLuaText('title')` },
}),
API({
id: "removeLuaText",
signature: "removeLuaText(tag, ?destroy)",
params: [["tag","String","Text tag to remove"],["destroy","Bool","If true, also destroys the text object","default false"]],
returns: "Void",
description: "Removes a text object from the display list. Optionally destroys it.",
code: { lang: "lua", source: `removeLuaText('old_label', true)` },
}),
API({
id: "luaTextExists",
signature: "luaTextExists(tag)",
params: [["tag","String","Text tag to check"]],
returns: "Bool",
description: "Returns <code>true</code> if a text object with the given tag has been created.",
code: { lang: "lua", source: `if luaTextExists('score') then
setTextString('score', '1000')
end` },
}),
{
id: "text-mutators",
title: "Text Mutators",
kind: "prose",
body: "Change the text content, appearance, and layout properties.",
},
API({
id: "setTextString",
signature: "setTextString(tag, text)",
params: [["tag","String","Text tag"],["text","String","New text content"]],
returns: "Void",
description: "Replaces the displayed text content.",
code: { lang: "lua", source: `setTextString('label', 'Score: ' .. score)` },
}),
API({
id: "setTextSize",
signature: "setTextSize(tag, size)",
params: [["tag","String","Text tag"],["size","Int","Font size in points"]],
returns: "Void",
description: "Sets the font size.",
code: { lang: "lua", source: `setTextSize('title', 32)` },
}),
API({
id: "setTextWidth",
signature: "setTextWidth(tag, width)",
params: [["tag","String","Text tag"],["width","Int","Field width in pixels"]],
returns: "Void",
description: "Sets the text field width. Use <code>0</code> for auto-size.",
code: { lang: "lua", source: `setTextWidth('description', 400)` },
}),
API({
id: "setTextHeight",
signature: "setTextHeight(tag, height)",
params: [["tag","String","Text tag"],["height","Int","Field height in pixels"]],
returns: "Void",
description: "Sets the text field height.",
code: { lang: "lua", source: `setTextHeight('panel', 200)` },
}),
API({
id: "setTextAutoSize",
signature: "setTextAutoSize(tag, value)",
params: [["tag","String","Text tag"],["value","Bool","Auto-size enabled?"]],
returns: "Void",
description: "Enables or disables automatic width/height based on text content.",
code: { lang: "lua", source: `setTextAutoSize('title', true)` },
}),
API({
id: "setTextBorder",
signature: "setTextBorder(tag, size, color, ?style)",
params: [["tag","String","Text tag"],["size","Float","Border thickness"],["color","String","Border color hex (<code>'RRGGBB'</code>)"],["style","String","<code>'outline'</code>, <code>'shadow'</code>, <code>'outline_fast'</code>, <code>'none'</code>","default 'outline'"]],
returns: "Void",
description: "Sets the text border style, thickness, and color.",
code: { lang: "lua", source: `setTextBorder('title', 2, '000000', 'outline')` },
}),
API({
id: "setTextColor",
signature: "setTextColor(tag, color)",
params: [["tag","String","Text tag"],["color","String","Text color hex (<code>'RRGGBB'</code>)"]],
returns: "Void",
description: "Sets the text fill color.",
code: { lang: "lua", source: `setTextColor('title', 'FF6699')` },
}),
API({
id: "setTextFont",
signature: "setTextFont(tag, newFont)",
params: [["tag","String","Text tag"],["newFont","String","Font name or path (resolved through <code>Paths.font</code>)"]],
returns: "Void",
description: "Sets the text font.",
code: { lang: "lua", source: `setTextFont('title', 'vcr')` },
}),
API({
id: "setTextItalic",
signature: "setTextItalic(tag, italic)",
params: [["tag","String","Text tag"],["italic","Bool","Enable italic style"]],
returns: "Void",
description: "Toggles italic text styling.",
code: { lang: "lua", source: `setTextItalic('quote', true)` },
}),
API({
id: "setTextAlignment",
signature: "setTextAlignment(tag, ?alignment)",
params: [["tag","String","Text tag"],["alignment","String","<code>'left'</code>, <code>'center'</code>, <code>'right'</code>","default 'left'"]],
returns: "Void",
description: "Sets the text alignment.",
code: { lang: "lua", source: `setTextAlignment('title', 'center')` },
}),
{
id: "text-getters",
title: "Text Getters",
kind: "prose",
body: "Read properties from existing text objects.",
},
API({
id: "getTextString",
signature: "getTextString(tag)",
params: [["tag","String","Text tag"]],
returns: "String",
description: "Returns the current text content.",
code: { lang: "lua", source: `local content = getTextString('label')` },
}),
API({
id: "getTextSize",
signature: "getTextSize(tag)",
params: [["tag","String","Text tag"]],
returns: "Int",
description: "Returns the current font size.",
code: { lang: "lua", source: `local size = getTextSize('title')` },
}),
API({
id: "getTextFont",
signature: "getTextFont(tag)",
params: [["tag","String","Text tag"]],
returns: "String",
description: "Returns the current font name.",
code: { lang: "lua", source: `local font = getTextFont('title')` },
}),
API({
id: "getTextWidth",
signature: "getTextWidth(tag)",
params: [["tag","String","Text tag"]],
returns: "Int",
description: "Returns the current text field width.",
code: { lang: "lua", source: `local w = getTextWidth('panel')` },
}),
],
},
/* ---------------- se-input ---------------- */
"se-input": {
title: "Input Functions",
category: "API Reference",
subtitle: "Query keyboard, mouse, and gamepad input. Keyboard functions accept <code>FlxKey</code> names (case-insensitive) — <code>'SPACE'</code>, <code>'A'</code>, <code>'ENTER'</code>, etc.",
sections: [
{
id: "input-keyboard",
title: "Keyboard — Game Keys",
kind: "prose",
body: "These respect the player's control bindings (LEFT/DOWN/UP/RIGHT). Use these for gameplay input.",
},
API({
id: "keyJustPressed",
signature: "keyJustPressed(name)",
params: [["name","String","Game key name: <code>'left'</code>, <code>'down'</code>, <code>'up'</code>, <code>'right'</code>, <code>'accept'</code>, <code>'back'</code>, <code>'pause'</code>, <code>'reset'</code>"]],
returns: "Bool",
description: "Returns <code>true</code> on the frame a game key is first pressed.",
code: { lang: "lua", source: `if keyJustPressed('space') then
print('jump!')
end` },
}),
API({
id: "keyPressed",
signature: "keyPressed(name)",
params: [["name","String","Game key name"]],
returns: "Bool",
description: "Returns <code>true</code> while a game key is held down.",
code: { lang: "lua", source: `if keyPressed('left') then
moveLeft()
end` },
}),
API({
id: "keyReleased",
signature: "keyReleased(name)",
params: [["name","String","Game key name"]],
returns: "Bool",
description: "Returns <code>true</code> on the frame a game key is released.",
code: { lang: "lua", source: `if keyReleased('accept') then
confirm()
end` },
}),
{
id: "input-raw-keyboard",
title: "Keyboard — Raw Keys",
kind: "prose",
body: "These query the physical keyboard directly, ignoring control bindings.",
},
API({
id: "keyboardJustPressed",
signature: "keyboardJustPressed(name)",
params: [["name","String","FlxKey name: <code>'SPACE'</code>, <code>'A'</code>, <code>'F1'</code>, etc."]],
returns: "Bool",
description: "Returns <code>true</code> on the frame a physical key is pressed.",
code: { lang: "lua", source: `if keyboardJustPressed('ESCAPE') then
openPauseMenu()
end` },
}),
API({
id: "keyboardPressed",
signature: "keyboardPressed(name)",
params: [["name","String","FlxKey name"]],
returns: "Bool",
description: "Returns <code>true</code> while a physical key is held.",
code: { lang: "lua", source: `if keyboardPressed('SHIFT') then
sprint()
end` },
}),
API({