-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamplesData.json
More file actions
2647 lines (2647 loc) · 121 KB
/
Copy pathexamplesData.json
File metadata and controls
2647 lines (2647 loc) · 121 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
{
"audio": [
{
"name": "Background Audio",
"uri": "background audio",
"thumb": "/examples/audio/background/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our variable to hold the audio",
" * Create our audio using Lightning built in this.game.audio.load",
" * Pass our key string for the audio",
" * Pass our array of files to load",
" * Set autoplay to false",
" * Set loop to true",
" * Set volumn to 1",
" */",
" let backgroundAudio = this.game.audio.load('background', ['/assets/audio.mp3'], false, true, 1);",
"",
" /**",
" * Call the play function on our audio variable.",
" */",
" backgroundAudio.play();",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "audio/background audio",
"parent": "audio"
},
{
"name": "Fade",
"uri": "fade",
"thumb": "/examples/audio/fade/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" /**",
" * Define a global boolean is the sound has been faded or not",
" */",
" private _isFaded:boolean;",
"",
" public create() {",
" /**",
" * Load our game audio",
" * Pass our key string for our sound",
" * Pass an array of sounds we wish to load from the directory we have them saved to",
" * Set autoplay to false",
" * Set looping to false",
" * Set our volumn to 1",
" */",
" this.game.audio.load('background', ['/assets/audio.mp3'], true, true, 1);",
"",
" /**",
" * Set our is faded boolean to false seeing as the audio has auto started and is not faded",
" */",
" this._isFaded = false;",
"",
" /**",
" * Create our text for our button",
" * Set text x and y anchor to 0.5",
" */",
" let btnText:Lightning.Text = new Lightning.Text('Click To Fade Out!', <any>{fontSize: 18});",
" btnText.anchor.x = 0.5;",
" btnText.anchor.y = 0.5;",
"",
"",
" /**",
" * Create our geometry shape for our button",
" */",
" let shape: Lightning.Geometry = Lightning.Geometry.RoundRect(200, 100, 20, 0xffffff, 1);",
"",
" /**",
" * Create a texture from our shape",
" */",
" let texture: Lightning.Texture = this.game.generateTexture(shape);",
"",
" /**",
" * Create our button sprite from our texture passing game context and texture",
" * Set our buttons x and y anchor to 0.5",
" * Set our buttons x and y position to game center",
" * Add text as a child to our button sprite",
" * Add button to game world",
" */",
" let button: Lightning.Button = new Lightning.Button(this.game, texture);",
" button.setAnchor(0.5);",
" button.x = this.game.center.x;",
" button.y = this.game.center.y;",
" button.addChild(btnText);",
" this.add(button);",
"",
" /**",
" * Create an on mouse down function",
" * Pass our button click function inside our lexical function",
" * We pass two variables to our button click function which are button, and btnText",
" */",
" button.on('mousedown', () => {",
" this.btnClick(button, btnText);",
" })",
" ",
" }",
"",
" /**",
" * Create our function to fire on button click which accepts button and btnText ",
" * ",
" */",
" private btnClick(button, btnText) {",
" /**",
" * If statement to check if our is faded boolean is false if it is continue",
" * Set our button tint to red",
" * Change our btnText text",
" * Call our fade function on our sound with the key string of 'background' fade accepts three required params. Volumn from, Volumn to, and speed in MS",
" * Set our is faded boolean to true",
" * ",
" * Next we have our Else If is faded boolean is true if it is continue",
" * Change our button tint to white",
" * Change our btnText text",
" * Call our fade function on our sound with the key string of 'background' changing the paramns to go from 0 to 1 at the same speed",
" * Set our is faded boolean back to false",
" */",
" if(this._isFaded == false) {",
" button.tint = 0xff0000;",
" btnText.text = \"Click Me To Fade In!\"",
" this.game.audio.sound('background').fade(1.0, 0.0, 1500);",
" this._isFaded = true;",
" } else if(this._isFaded == true) {",
" button.tint = 0xffffff;;",
" btnText.text = \"Click Me To Fade Out!\"",
" this.game.audio.sound('background').fade(0.0, 1.0, 1500);",
" this._isFaded = false;",
" }",
" ",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "audio/fade",
"parent": "audio"
},
{
"name": "On Click Sound",
"uri": "on click sound",
"thumb": "/examples/audio/on click/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
"",
" /**",
" * Load our game audio",
" * Pass our key string for our sound",
" * Pass an array of sounds we wish to load from the directory we have them saved to",
" * Set autoplay to false",
" * Set looping to false",
" * Set our volumn to 1",
" */",
" this.game.audio.load('boom', ['/assets/boom.wav'], false, false, 1);",
"",
" /**",
" * Create our text for our button",
" * Set text x and y anchor to 0.5",
" */",
" let text:Lightning.Text = new Lightning.Text('Click Me!', <any>{fontSize: 24});",
" text.anchor.x = 0.5;",
" text.anchor.y = 0.5;",
"",
"",
" /**",
" * Create our geometry shape for our button",
" */",
" let shape: Lightning.Geometry = Lightning.Geometry.RoundRect(200, 100, 20, 0xffffff, 1);",
"",
" /**",
" * Create a texture from our shape",
" */",
" let texture: Lightning.Texture = this.game.generateTexture(shape);",
"",
" /**",
" * Create our button sprite from our texture passing game context and texture",
" * Set our buttons x and y anchor to 0.5",
" * Set our buttons x and y position to game center",
" * Add text as a child to our button sprite",
" * Add button to game world",
" */",
" let button: Lightning.Button = new Lightning.Button(this.game, texture);",
" button.setAnchor(0.5);",
" button.x = this.game.center.x;",
" button.y = this.game.center.y;",
" button.addChild(text);",
" this.add(button);",
"",
" /**",
" * Create an on mouse down function",
" * Pass our button click function inside our lexical function",
" */",
" button.on('mousedown', () => {",
" this.btnClick();",
" })",
" ",
" }",
"",
" /**",
" * Create our function to fire on button click",
" * Play our sound when function is fired",
" */",
" private btnClick() {",
" this.game.audio.sound('boom').play();",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "audio/on click sound",
"parent": "audio"
},
{
"name": "Pause Sound",
"uri": "pause sound",
"thumb": "/examples/audio/pause/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" /**",
" * Create global vaiable to hold our is playing boolean",
" */",
" private _isPlaying:boolean;",
"",
" public create() {",
"",
" /**",
" * Load our game audio",
" * Pass our key string for our sound",
" * Pass an array of sounds we wish to load from the directory we have them saved to",
" * Set autoplay to true",
" * Set looping to true",
" * Set our volumn to 1",
" */",
" this.game.audio.load('background', ['/assets/audio.mp3'], true, true, 1);",
"",
" /**",
" * Set global is playing boolean to true since we set autoplay to true and our sound is playing",
" */",
" this._isPlaying = true;",
"",
" /**",
" * Create our text for our button",
" * Set text x and y anchor to 0.5",
" */",
" let buttonText:Lightning.Text = new Lightning.Text('Pause!', <any>{fontSize: 24});",
" buttonText.anchor.x = 0.5;",
" buttonText.anchor.y = 0.5;",
"",
"",
" /**",
" * Create our geometry shape for our button",
" */",
" let shape: Lightning.Geometry = Lightning.Geometry.RoundRect(200, 100, 20, 0xffffff, 1);",
"",
" /**",
" * Create a texture from our shape",
" */",
" let texture: Lightning.Texture = this.game.generateTexture(shape);",
"",
" /**",
" * Create our button sprite from our texture passing game context and texture",
" * Set our buttons x and y anchor to 0.5",
" * Set our buttons x and y position to game center",
" * Add text as a child to our button sprite",
" * Add button to game world",
" */",
" let button: Lightning.Button = new Lightning.Button(this.game, texture);",
" button.setAnchor(0.5);",
" button.x = this.game.center.x;",
" button.y = this.game.center.y;",
" button.addChild(buttonText);",
" this.add(button);",
"",
" /**",
" * Create an on mouse down function",
" * Pass our button click function inside our lexical function",
" * We pass two variables to our function, the button, and the button text",
" */",
" button.on('mousedown', () => {",
" this.btnClick(button, buttonText);",
" })",
" ",
" }",
"",
" /**",
" * Create our function to fire on button click",
" * ",
" */",
" private btnClick(button,buttonText) {",
" /**",
" * Create if statement to trigger if our is playing boolean is true when button is clicked",
" * Pause our game sound with key we pass from the creation of the audio",
" * Change the tint of our button to show it has been clicked to pause",
" * Change our text from 'Pause!' to 'Unpause!'",
" * Set our is playing boolean to false since it has now been muted",
" * ",
" * Else If statement to trigger if our is playing boolean is false when button is clicked",
" * Unpause our game sound with key we pass from the creation of the audio",
" * Change the tint of our button to show it has been clicked to pause",
" * Change our text from 'Unpause!' back to 'Pause!'",
" * Set our is playing boolean back to true since the game audio has now been unmuted.",
" */",
" if(this._isPlaying == true) {",
" this.game.audio.sound('background').pause();",
" button.tint = 0xff0000;",
" buttonText.text = 'Unpause!';",
" this._isPlaying = false;",
" }else if(this._isPlaying == false){",
" button.tint = 0xffffff;",
" buttonText.text = 'Pause!'; ",
" this.game.audio.sound('background').play(); ",
" this._isPlaying = true;",
" ",
" }",
" ",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "audio/pause sound",
"parent": "audio"
},
{
"name": "Rate",
"uri": "rate",
"thumb": "/examples/audio/rate/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" /**",
" * Define a global rate variable for our rate to 1.",
" */",
" private _rate:number = 1;",
"",
" public create() {",
" /**",
" * Load our game audio",
" * Pass our key string for our sound",
" * Pass an array of sounds we wish to load from the directory we have them saved to",
" * Set autoplay to true",
" * Set looping to true",
" * Set our rate to our predefined rate variable which is set to 1",
" */",
" // this.game.audio.load('background', ['/assets/audio.mp3'], false, true, this._rate);",
" let backgroundSound = this.game.audio.load('background', ['/assets/audio.mp3'], true, true, this._rate);",
"",
" /**",
" * Create our text for our button",
" * Set text x and y anchor to 0.5",
" */",
" let btnText:Lightning.Text = new Lightning.Text('Speed: 1', <any>{fontSize: 18});",
" btnText.anchor.x = 0.5;",
" btnText.anchor.y = 0.5;",
"",
"",
" /**",
" * Create our geometry shape for our button",
" */",
" let shape: Lightning.Geometry = Lightning.Geometry.RoundRect(200, 100, 20, 0xffffff, 1);",
"",
" /**",
" * Create a texture from our shape",
" */",
" let texture: Lightning.Texture = this.game.generateTexture(shape);",
"",
" /**",
" * Create our button sprite from our texture passing game context and texture",
" * Set our buttons x and y anchor to 0.5",
" * Set our buttons x and y position to game center",
" * Add text as a child to our button sprite",
" * Add button to game world",
" */",
" let button: Lightning.Button = new Lightning.Button(this.game, texture);",
" button.setAnchor(0.5);",
" button.x = this.game.center.x;",
" button.y = this.game.center.y;",
" button.addChild(btnText);",
" this.add(button);",
"",
" /**",
" * Create an on mouse down function",
" * Pass our button click function inside our lexical function",
" * We pass two variables to our button click function which are button, and btnText",
" */",
" button.on('mousedown', () => {",
" this.btnClick(button, btnText);",
" })",
" ",
" }",
"",
" /**",
" * Create our function to fire on button click which accepts button and btnText ",
" * ",
" */",
" private btnClick(button, btnText) {",
" /**",
" * When the function is fired increase our rate vaiable by 0.5",
" * Create our if statement, if our rate variable is larger than 1.5 then set the rate to 0.5",
" */",
" this._rate += 0.5;",
" if(this._rate > 1.5) {",
" this._rate = 0.5;",
" }",
"",
" /**",
" * Set our rate to the varibale above",
" * Change button text to \"Spped:\" + whatever our rate is currently at",
" */",
"",
" this.game.audio.sound('background').rate(this._rate);",
" btnText.text = \"Speed:\" + this._rate;",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "audio/rate",
"parent": "audio"
}
],
"geometry": [
{
"name": "Circle",
"uri": "circle",
"thumb": "/examples/geometry/circle/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our shape using Lightning Geometry Circle function",
" * Inside our function pass our radius, tint, and alpha",
" */",
" let shape:Lightning.Geometry = Lightning.Geometry.Circle(50, 0xffffff, 1);",
"",
" //Create a texture from our Geometry shape.",
" let texture:Lightning.Texture = this.game.generateTexture(shape);",
" ",
" /**",
" * Create our sprite from our texture",
" * Set sprite x and y positions to game center",
" * Add sprite to our game world",
" */",
" let sprite:Lightning.Sprite = new Lightning.Sprite(this.game.texture(texture));",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" this.add(sprite);",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "geometry/circle",
"parent": "geometry"
},
{
"name": "Rectangle",
"uri": "rectangle",
"thumb": "/examples/geometry/rectangle/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our shape using Lightning Geometry Rect function",
" * Inside our function pass our width, height, tint, and alpha",
" */",
" let shape:Lightning.Geometry = Lightning.Geometry.Rect(100, 50, 0xffffff, 1);",
"",
" //Create a texture from our Geometry shape.",
" let texture:Lightning.Texture = this.game.generateTexture(shape);",
" ",
" /**",
" * Create our sprite from our texture",
" * Set sprite x and y positions to game center",
" * Add sprite to our game world",
" */",
" let sprite:Lightning.Sprite = new Lightning.Sprite(this.game.texture(texture));",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" this.add(sprite);",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "geometry/rectangle",
"parent": "geometry"
},
{
"name": "Round Rectangle",
"uri": "round rectangle",
"thumb": "/examples/geometry/round rectangle/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our shape using Lightning Geometry RoundRect function",
" * Inside our function pass our width, height, radius, tint, and alpha",
" */",
" let shape:Lightning.Geometry = Lightning.Geometry.RoundRect(200, 100, 20, 0xffffff, 1);",
"",
" //Create a texture from our Geometry shape.",
" let texture:Lightning.Texture = this.game.generateTexture(shape);",
" ",
" /**",
" * Create our sprite from our texture",
" * Set sprite x and y positions to game center",
" * Add sprite to our game world",
" */",
" let sprite:Lightning.Sprite = new Lightning.Sprite(this.game.texture(texture));",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" this.add(sprite);",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "geometry/round rectangle",
"parent": "geometry"
},
{
"name": "Square",
"uri": "square",
"thumb": "/examples/geometry/square/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our shape using Lightning Geometry Square function",
" * Inside our function pass our dimension, tint, and alpha",
" */",
" let shape:Lightning.Geometry = Lightning.Geometry.Square(100, 0xffffff, 1);",
"",
" //Create a texture from our Geometry shape.",
" let texture:Lightning.Texture = this.game.generateTexture(shape);",
" ",
" /**",
" * Create our sprite from our texture",
" * Set sprite x and y positions to game center",
" * Add sprite to our game world",
" */",
" let sprite:Lightning.Sprite = new Lightning.Sprite(this.game.texture(texture));",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" this.add(sprite);",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "geometry/square",
"parent": "geometry"
},
{
"name": "Triangle",
"uri": "triangle",
"thumb": "/examples/geometry/triangle/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" /**",
" * Create our shape using Lightning Geometry Trianle function",
" * Inside our function pass our lengths for our sides, tint, and alpha",
" */",
" let shape:Lightning.Geometry = Lightning.Geometry.Triangle(200, 200, 0xffffff, 1);",
"",
" //Create a texture from our Geometry shape.",
" let texture:Lightning.Texture = this.game.generateTexture(shape);",
" ",
" /**",
" * Create our sprite from our texture",
" * Set sprite x and y positions to game center",
" * Add sprite to our game world",
" */",
" let sprite:Lightning.Sprite = new Lightning.Sprite(this.game.texture(texture));",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" this.add(sprite);",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "geometry/triangle",
"parent": "geometry"
}
],
"input": [
{
"name": "Click",
"uri": "click",
"thumb": "/examples/input/click/thumb.png",
"version": "0.5.1",
"tabs": [
{
"name": "Info",
"id": "info",
"desc": "",
"src_file": "info.txt",
"language": "markdown",
"value": [
"Here is some text.",
"Lets go ahead and populate some stuff here.",
"You will want to do:",
"A.",
"B.",
"C.",
" 1.",
" 2.",
"D."
]
},
{
"name": "Game State",
"id": "game-state",
"desc": "",
"src_file": "src/ts/scenes/game.ts",
"language": "typescript",
"value": [
"export default class GameScene extends Lightning.Scene {",
"",
" public create() {",
" //Define graphics",
" let graphics: Lightning.Graphics = Lightning.Geometry.Square(100, 0xffffff);",
"",
" //Create a texture from our graphics opject",
" let texture: Lightning.Texture = graphics.generateCanvasTexture();",
"",
" /**",
" * Create text to append to our sprite that is draggable",
" * Set text anchor x and y to center",
" */",
" let spriteText: Lightning.Text = new Lightning.Text('Click Me!', <any>{ fontSize: 24, fill: 0x000000",
" });",
" spriteText.anchor.x = 0.5;",
" spriteText.anchor.y = 0.5;",
"",
" /**",
" * Create our sprite",
" * Set our x and y positions for game center",
" * Set our sprites anchor to 0.5 which is center of the sprite",
" * Add out text to our sprite to tell everyone its clickable",
" * Add our sprite to game world",
" */",
" let sprite: Lightning.Sprite = new Lightning.Sprite(texture);",
" sprite.x = this.game.center.x;",
" sprite.y = this.game.center.y;",
" sprite.setAnchor(0.5);",
" sprite.interactive = true;",
" sprite.addChild(spriteText);",
" this.add(sprite);",
" ",
"",
" /**",
" * Create an on mouse down function",
" * Pass our button click function inside our lexical function which accepts our sprite",
" */",
" sprite.on('mouseup', () => {",
" this.spriteClick(sprite);",
" });",
" }",
"",
" /**",
" * Create our function to fire on button click",
" */",
" spriteClick(sprite) {",
"",
" /**",
" * Create an empty array to hold our randomly generated hex color for our button",
" */",
" let arr:Array<number | string> = [];",
"",
" /**",
" * Create a for loop that triggers 6 times",
" */",
" for(let i = 0; i < 6; i++) {",
" /**",
" * For each loop create a random number between 0, 9 using Lightning Maths",
" */",
" let ranNum = Lightning.Maths.rngInt(0, 9);",
"",
" /**",
" * Push that random number to the array",
" */",
" arr.push(ranNum);",
" }",
"",
" /**",
" * Prefix our array of 6 numbers with 0x to tell the renderer that its a color code",
" */",
" arr.unshift('0x');",
"",
" /**",
" * Define a variable called color and use javascripts array join functionality to just have a space between numbers instead of a comma",
" */",
" let color = arr.join(\"\");",
"",
" /**",
" * Set our sprites tint equal to the random color generated",
" */",
" sprite.tint = color;",
" }",
"}"
]
}
],
"scriptSrc": "game.js",
"url": "input/click",
"parent": "input"
},
{
"name": "Drag",
"uri": "drag",
"thumb": "/examples/input/drag/thumb.png",
"version": "0.5.1",
"tabs": [