brick-engine-js 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.adoc +1 -1
- package/dist/docs/index.html +2 -2
- package/dist/docs/reference/enums/ControlKey.html +4 -0
- package/dist/docs/reference/enums/ScoreProperty.html +526 -0
- package/dist/docs/reference/enums/StateProperty.html +4 -0
- package/dist/docs/reference/interfaces/StateSyncable.html +1 -1
- package/dist/docs/reference/interfaces/modules/Score.html +182 -32
- package/dist/docs/reference/interfaces/modules/State.html +88 -36
- package/dist/docs/reference/interfaces/modules/Time.html +61 -145
- package/dist/docs/reference/modules/GameEventRegistry.html +10 -4
- package/dist/docs/reference/modules/GameScore.html +339 -71
- package/dist/docs/reference/modules/GameState.html +256 -163
- package/dist/docs/reference/modules/GameTime.html +136 -149
- package/dist/game.bundle.js +1 -1
- package/dist/types/config/configs.d.ts +2 -4
- package/dist/types/core/Game.d.ts +17 -10
- package/dist/types/core/module/score/GameScore.d.ts +24 -0
- package/dist/types/core/module/time/GameTime.d.ts +62 -63
- package/dist/types/core/types/enums.d.ts +11 -0
- package/dist/types/core/types/modules.d.ts +70 -60
- package/dist/types/view/ShortcutsModal.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -443,75 +443,130 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
443
443
|
<div id="toc" class="toc2">
|
|
444
444
|
<div id="toctitle">Table of Contents</div>
|
|
445
445
|
<ul class="sectlevel1">
|
|
446
|
-
<li><a href="#
|
|
447
|
-
<li><a href="#api-reference">2. API Reference</a>
|
|
446
|
+
<li><a href="#api-reference">1. API Reference</a>
|
|
448
447
|
<ul class="sectlevel2">
|
|
449
|
-
<li><a href="#
|
|
450
|
-
<
|
|
451
|
-
<li><a href="#
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
<li><a href="#
|
|
455
|
-
<
|
|
456
|
-
<li><a href="#
|
|
457
|
-
<li><a href="#
|
|
458
|
-
<li><a href="#
|
|
459
|
-
<li><a href="#
|
|
460
|
-
|
|
461
|
-
|
|
448
|
+
<li><a href="#life-cycle">1.1. Life Cycle</a>
|
|
449
|
+
<ul class="sectlevel3">
|
|
450
|
+
<li><a href="#setupgamehighscoreid-string-void">1.1.1. <code>setupGameHighScore(id: string): void</code></a></li>
|
|
451
|
+
</ul>
|
|
452
|
+
</li>
|
|
453
|
+
<li><a href="#score-management">1.2. Score Management</a>
|
|
454
|
+
<ul class="sectlevel3">
|
|
455
|
+
<li><a href="#score-number">1.2.1. <code>score: number</code></a></li>
|
|
456
|
+
<li><a href="#increasescoreamount-number-void">1.2.2. <code>increaseScore(amount: number): void</code></a></li>
|
|
457
|
+
<li><a href="#resetscore-void">1.2.3. <code>resetScore(): void</code></a></li>
|
|
458
|
+
<li><a href="#highscore-number">1.2.4. <code>highScore: number</code></a></li>
|
|
459
|
+
</ul>
|
|
460
|
+
</li>
|
|
461
|
+
<li><a href="#level-management">1.3. Level Management</a>
|
|
462
|
+
<ul class="sectlevel3">
|
|
463
|
+
<li><a href="#level-number">1.3.1. <code>level: number</code></a></li>
|
|
464
|
+
<li><a href="#increaselevelamount-number-void">1.3.2. <code>increaseLevel(amount: number): void</code></a></li>
|
|
465
|
+
<li><a href="#resetlevel-void">1.3.3. <code>resetLevel(): void</code></a></li>
|
|
466
|
+
<li><a href="#maxlevel-number">1.3.4. <code>maxLevel: number</code></a></li>
|
|
467
|
+
</ul>
|
|
468
|
+
</li>
|
|
469
|
+
<li><a href="#subscriptions">1.4. Subscriptions</a>
|
|
470
|
+
<ul class="sectlevel3">
|
|
471
|
+
<li><a href="#subscribecallback-score-number-void-void">1.4.1. <code>subscribe(callback: (score: number) ⇒ void): void</code></a></li>
|
|
472
|
+
<li><a href="#unsubscribecallback-score-number-void-void">1.4.2. <code>unsubscribe(callback: (score: number) ⇒ void): void</code></a></li>
|
|
473
|
+
</ul>
|
|
474
|
+
</li>
|
|
475
|
+
<li><a href="#utility-state">1.5. Utility & State</a>
|
|
476
|
+
<ul class="sectlevel3">
|
|
477
|
+
<li><a href="#multiplier-number">1.5.1. <code>multiplier: number</code></a></li>
|
|
478
|
+
<li><a href="#getformattedscoredigits-number-string">1.5.2. <code>getFormattedScore(digits: number): string</code></a></li>
|
|
479
|
+
<li><a href="#serialize-string">1.5.3. <code>serialize(): string</code></a></li>
|
|
480
|
+
<li><a href="#deserializedata-string-void">1.5.4. <code>deserialize(data: string): void</code></a></li>
|
|
481
|
+
<li><a href="#getdebugdata-recordstring-string-number-boolean">1.5.5. <code>getDebugData(): Record<string, string | number | boolean></code></a></li>
|
|
482
|
+
</ul>
|
|
483
|
+
</li>
|
|
462
484
|
</ul>
|
|
463
485
|
</li>
|
|
464
486
|
</ul>
|
|
465
487
|
</div>
|
|
466
488
|
</div>
|
|
467
489
|
<div id="content">
|
|
468
|
-
<div
|
|
469
|
-
<h2 id="architectural-purpose"><a class="link" href="#architectural-purpose">1. Architectural Purpose</a></h2>
|
|
490
|
+
<div id="preamble">
|
|
470
491
|
<div class="sectionbody">
|
|
471
492
|
<div class="paragraph">
|
|
472
493
|
<p>The <code>GameScore</code> module acts as the strict authority dedicated to tracking real-time player performance metrics, levels, and point multipliers. It prevents transient session logic from interacting with persistent storage, explicitly taking over saving the global <code>highScore</code> into an isolated <code>LocalStorage</code> namespace directly, ensuring different game engines do not overwrite each other’s records.</p>
|
|
473
494
|
</div>
|
|
495
|
+
<div class="paragraph">
|
|
496
|
+
<p>It exposes reactivity through an event-based system using <code><a href="../enums/ScoreProperty.html">ScoreProperty</a></code>.</p>
|
|
497
|
+
</div>
|
|
474
498
|
</div>
|
|
475
499
|
</div>
|
|
476
500
|
<div class="sect1">
|
|
477
|
-
<h2 id="api-reference"><a class="link" href="#api-reference">
|
|
501
|
+
<h2 id="api-reference"><a class="link" href="#api-reference">1. API Reference</a></h2>
|
|
478
502
|
<div class="sectionbody">
|
|
479
503
|
<div class="sect2">
|
|
480
|
-
<h3 id="
|
|
504
|
+
<h3 id="life-cycle"><a class="link" href="#life-cycle">1.1. Life Cycle</a></h3>
|
|
481
505
|
<div class="paragraph">
|
|
482
|
-
<p>
|
|
483
|
-
</div>
|
|
484
|
-
<hr>
|
|
506
|
+
<p>Methods for initializing the high score context.</p>
|
|
485
507
|
</div>
|
|
486
|
-
<div class="
|
|
487
|
-
<
|
|
508
|
+
<div class="sect3">
|
|
509
|
+
<h4 id="setupgamehighscoreid-string-void"><a class="link" href="#setupgamehighscoreid-string-void">1.1.1. <code>setupGameHighScore(id: string): void</code></a></h4>
|
|
488
510
|
<div class="paragraph">
|
|
489
|
-
<p>
|
|
511
|
+
<p>Initializes the module with the specific game ID and loads the corresponding high score.</p>
|
|
490
512
|
</div>
|
|
491
|
-
<
|
|
513
|
+
<div class="paragraph">
|
|
514
|
+
<p><strong>Parameters</strong></p>
|
|
492
515
|
</div>
|
|
493
|
-
<
|
|
494
|
-
<
|
|
516
|
+
<table class="tableblock frame-all grid-all stretch">
|
|
517
|
+
<colgroup>
|
|
518
|
+
<col style="width: 20%;">
|
|
519
|
+
<col style="width: 20%;">
|
|
520
|
+
<col style="width: 60%;">
|
|
521
|
+
</colgroup>
|
|
522
|
+
<thead>
|
|
523
|
+
<tr>
|
|
524
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
525
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
526
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
527
|
+
</tr>
|
|
528
|
+
</thead>
|
|
529
|
+
<tbody>
|
|
530
|
+
<tr>
|
|
531
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>id</code></p></td>
|
|
532
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>string</code></p></td>
|
|
533
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock">The unique game UUID identifier used as a persistent prefix for namespace isolation.</p></td>
|
|
534
|
+
</tr>
|
|
535
|
+
</tbody>
|
|
536
|
+
</table>
|
|
495
537
|
<div class="paragraph">
|
|
496
|
-
<p>
|
|
538
|
+
<p><strong>Example</strong></p>
|
|
539
|
+
</div>
|
|
540
|
+
<div class="listingblock">
|
|
541
|
+
<div class="content">
|
|
542
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.setupGameHighScore("tetris-v1");</code></pre>
|
|
543
|
+
</div>
|
|
497
544
|
</div>
|
|
498
545
|
<hr>
|
|
499
546
|
</div>
|
|
547
|
+
</div>
|
|
500
548
|
<div class="sect2">
|
|
501
|
-
<h3 id="
|
|
549
|
+
<h3 id="score-management"><a class="link" href="#score-management">1.2. Score Management</a></h3>
|
|
502
550
|
<div class="paragraph">
|
|
503
|
-
<p>
|
|
551
|
+
<p>Methods for adding and resetting points.</p>
|
|
504
552
|
</div>
|
|
553
|
+
<div class="sect3">
|
|
554
|
+
<h4 id="score-number"><a class="link" href="#score-number">1.2.1. <code>score: number</code></a></h4>
|
|
505
555
|
<div class="paragraph">
|
|
506
|
-
<p
|
|
556
|
+
<p>Read-only property returning the current session’s points.</p>
|
|
507
557
|
</div>
|
|
508
558
|
<div class="paragraph">
|
|
509
|
-
<p>
|
|
559
|
+
<p><strong>Example</strong></p>
|
|
560
|
+
</div>
|
|
561
|
+
<div class="listingblock">
|
|
562
|
+
<div class="content">
|
|
563
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">console.log(`Current Score: ${core.score.score}`);</code></pre>
|
|
564
|
+
</div>
|
|
510
565
|
</div>
|
|
511
566
|
<hr>
|
|
512
567
|
</div>
|
|
513
|
-
<div class="
|
|
514
|
-
<
|
|
568
|
+
<div class="sect3">
|
|
569
|
+
<h4 id="increasescoreamount-number-void"><a class="link" href="#increasescoreamount-number-void">1.2.2. <code>increaseScore(amount: number): void</code></a></h4>
|
|
515
570
|
<div class="paragraph">
|
|
516
571
|
<p>Adds points to the current session.</p>
|
|
517
572
|
</div>
|
|
@@ -524,12 +579,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
524
579
|
<col style="width: 20%;">
|
|
525
580
|
<col style="width: 60%;">
|
|
526
581
|
</colgroup>
|
|
527
|
-
<
|
|
582
|
+
<thead>
|
|
528
583
|
<tr>
|
|
529
|
-
<
|
|
530
|
-
<
|
|
531
|
-
<
|
|
584
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
585
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
586
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
532
587
|
</tr>
|
|
588
|
+
</thead>
|
|
589
|
+
<tbody>
|
|
533
590
|
<tr>
|
|
534
591
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>amount</code></p></td>
|
|
535
592
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
|
|
@@ -541,19 +598,80 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
541
598
|
<p><strong>Behavior</strong></p>
|
|
542
599
|
</div>
|
|
543
600
|
<div class="paragraph">
|
|
544
|
-
<p>Increases the score by <code>amount * multiplier</code>. Automatically compares the new score against the internal <code>highScore</code> property and updates it if a new record is reached (which in turn persists the new record to <code>LocalStorage</code>)
|
|
601
|
+
<p>Increases the score by <code>amount * multiplier</code>. Automatically compares the new score against the internal <code>highScore</code> property and updates it if a new record is reached (which in turn persists the new record to <code>LocalStorage</code>). Triggers a <code>SCORE</code> notification via the <code><a href="EventEmitter.html">EventEmitter</a></code>.</p>
|
|
602
|
+
</div>
|
|
603
|
+
<div class="paragraph">
|
|
604
|
+
<p><strong>Example</strong></p>
|
|
605
|
+
</div>
|
|
606
|
+
<div class="listingblock">
|
|
607
|
+
<div class="content">
|
|
608
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">// Adds 500 * current multiplier to the score
|
|
609
|
+
core.score.increaseScore(500);</code></pre>
|
|
610
|
+
</div>
|
|
545
611
|
</div>
|
|
546
612
|
<hr>
|
|
547
613
|
</div>
|
|
548
|
-
<div class="
|
|
549
|
-
<
|
|
614
|
+
<div class="sect3">
|
|
615
|
+
<h4 id="resetscore-void"><a class="link" href="#resetscore-void">1.2.3. <code>resetScore(): void</code></a></h4>
|
|
616
|
+
<div class="paragraph">
|
|
617
|
+
<p>Resets the session score to zero. Triggers a <code>SCORE</code> notification.</p>
|
|
618
|
+
</div>
|
|
619
|
+
<div class="paragraph">
|
|
620
|
+
<p><strong>Example</strong></p>
|
|
621
|
+
</div>
|
|
622
|
+
<div class="listingblock">
|
|
623
|
+
<div class="content">
|
|
624
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.resetScore();</code></pre>
|
|
625
|
+
</div>
|
|
626
|
+
</div>
|
|
627
|
+
<hr>
|
|
628
|
+
</div>
|
|
629
|
+
<div class="sect3">
|
|
630
|
+
<h4 id="highscore-number"><a class="link" href="#highscore-number">1.2.4. <code>highScore: number</code></a></h4>
|
|
631
|
+
<div class="paragraph">
|
|
632
|
+
<p>Read and Write property for the highest overall score achieved.</p>
|
|
633
|
+
</div>
|
|
634
|
+
<div class="paragraph">
|
|
635
|
+
<p><strong>Behavior</strong></p>
|
|
636
|
+
</div>
|
|
637
|
+
<div class="paragraph">
|
|
638
|
+
<p>When set, it automatically persists the value directly to <code>LocalStorage</code> under the namespaced key <code>${gameId}::highScore</code>. This ensures that different games do not overwrite each other’s records. Triggers a <code>HIGH_SCORE</code> notification.</p>
|
|
639
|
+
</div>
|
|
550
640
|
<div class="paragraph">
|
|
551
|
-
<p>
|
|
641
|
+
<p><strong>Example</strong></p>
|
|
642
|
+
</div>
|
|
643
|
+
<div class="listingblock">
|
|
644
|
+
<div class="content">
|
|
645
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">console.log(`High Score to beat: ${core.score.highScore}`);</code></pre>
|
|
646
|
+
</div>
|
|
552
647
|
</div>
|
|
553
648
|
<hr>
|
|
554
649
|
</div>
|
|
650
|
+
</div>
|
|
555
651
|
<div class="sect2">
|
|
556
|
-
<h3 id="
|
|
652
|
+
<h3 id="level-management"><a class="link" href="#level-management">1.3. Level Management</a></h3>
|
|
653
|
+
<div class="paragraph">
|
|
654
|
+
<p>Methods for difficulty scaling.</p>
|
|
655
|
+
</div>
|
|
656
|
+
<div class="sect3">
|
|
657
|
+
<h4 id="level-number"><a class="link" href="#level-number">1.3.1. <code>level: number</code></a></h4>
|
|
658
|
+
<div class="paragraph">
|
|
659
|
+
<p>Read-only property returning the current difficulty level.</p>
|
|
660
|
+
</div>
|
|
661
|
+
<div class="paragraph">
|
|
662
|
+
<p><strong>Example</strong></p>
|
|
663
|
+
</div>
|
|
664
|
+
<div class="listingblock">
|
|
665
|
+
<div class="content">
|
|
666
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">if (core.score.level > 10) {
|
|
667
|
+
unlockSecretLevel();
|
|
668
|
+
}</code></pre>
|
|
669
|
+
</div>
|
|
670
|
+
</div>
|
|
671
|
+
<hr>
|
|
672
|
+
</div>
|
|
673
|
+
<div class="sect3">
|
|
674
|
+
<h4 id="increaselevelamount-number-void"><a class="link" href="#increaselevelamount-number-void">1.3.2. <code>increaseLevel(amount: number): void</code></a></h4>
|
|
557
675
|
<div class="paragraph">
|
|
558
676
|
<p>Increases the game difficulty level.</p>
|
|
559
677
|
</div>
|
|
@@ -566,12 +684,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
566
684
|
<col style="width: 20%;">
|
|
567
685
|
<col style="width: 60%;">
|
|
568
686
|
</colgroup>
|
|
569
|
-
<
|
|
687
|
+
<thead>
|
|
570
688
|
<tr>
|
|
571
|
-
<
|
|
572
|
-
<
|
|
573
|
-
<
|
|
689
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
690
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
691
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
574
692
|
</tr>
|
|
693
|
+
</thead>
|
|
694
|
+
<tbody>
|
|
575
695
|
<tr>
|
|
576
696
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>amount</code></p></td>
|
|
577
697
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
|
|
@@ -579,19 +699,62 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
579
699
|
</tr>
|
|
580
700
|
</tbody>
|
|
581
701
|
</table>
|
|
702
|
+
<div class="paragraph">
|
|
703
|
+
<p><strong>Behavior</strong></p>
|
|
704
|
+
</div>
|
|
705
|
+
<div class="paragraph">
|
|
706
|
+
<p>Increases the internal level and triggers a <code>LEVEL</code> notification.</p>
|
|
707
|
+
</div>
|
|
708
|
+
<div class="paragraph">
|
|
709
|
+
<p><strong>Example</strong></p>
|
|
710
|
+
</div>
|
|
711
|
+
<div class="listingblock">
|
|
712
|
+
<div class="content">
|
|
713
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.increaseLevel(1);</code></pre>
|
|
714
|
+
</div>
|
|
715
|
+
</div>
|
|
582
716
|
<hr>
|
|
583
717
|
</div>
|
|
584
|
-
<div class="
|
|
585
|
-
<
|
|
718
|
+
<div class="sect3">
|
|
719
|
+
<h4 id="resetlevel-void"><a class="link" href="#resetlevel-void">1.3.3. <code>resetLevel(): void</code></a></h4>
|
|
720
|
+
<div class="paragraph">
|
|
721
|
+
<p>Resets the level counter to 1. Triggers a <code>LEVEL</code> notification.</p>
|
|
722
|
+
</div>
|
|
586
723
|
<div class="paragraph">
|
|
587
|
-
<p>
|
|
588
|
-
|
|
724
|
+
<p><strong>Example</strong></p>
|
|
725
|
+
</div>
|
|
726
|
+
<div class="listingblock">
|
|
727
|
+
<div class="content">
|
|
728
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.resetLevel();</code></pre>
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
<hr>
|
|
732
|
+
</div>
|
|
733
|
+
<div class="sect3">
|
|
734
|
+
<h4 id="maxlevel-number"><a class="link" href="#maxlevel-number">1.3.4. <code>maxLevel: number</code></a></h4>
|
|
735
|
+
<div class="paragraph">
|
|
736
|
+
<p>Read and Write property for the maximum game level cap. Triggers a <code>MAX_LEVEL</code> notification on change.</p>
|
|
737
|
+
</div>
|
|
738
|
+
<div class="paragraph">
|
|
739
|
+
<p><strong>Example</strong></p>
|
|
740
|
+
</div>
|
|
741
|
+
<div class="listingblock">
|
|
742
|
+
<div class="content">
|
|
743
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.maxLevel = 25;</code></pre>
|
|
744
|
+
</div>
|
|
745
|
+
</div>
|
|
746
|
+
<hr>
|
|
589
747
|
</div>
|
|
590
748
|
</div>
|
|
591
749
|
<div class="sect2">
|
|
592
|
-
<h3 id="
|
|
750
|
+
<h3 id="subscriptions"><a class="link" href="#subscriptions">1.4. Subscriptions</a></h3>
|
|
593
751
|
<div class="paragraph">
|
|
594
|
-
<p>
|
|
752
|
+
<p>Enables other modules to listen for score-related updates.</p>
|
|
753
|
+
</div>
|
|
754
|
+
<div class="sect3">
|
|
755
|
+
<h4 id="subscribecallback-score-number-void-void"><a class="link" href="#subscribecallback-score-number-void-void">1.4.1. <code>subscribe(callback: (score: number) ⇒ void): void</code></a></h4>
|
|
756
|
+
<div class="paragraph">
|
|
757
|
+
<p>Registers a listener for score changes.</p>
|
|
595
758
|
</div>
|
|
596
759
|
<div class="paragraph">
|
|
597
760
|
<p><strong>Parameters</strong></p>
|
|
@@ -602,23 +765,93 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
602
765
|
<col style="width: 20%;">
|
|
603
766
|
<col style="width: 60%;">
|
|
604
767
|
</colgroup>
|
|
768
|
+
<thead>
|
|
769
|
+
<tr>
|
|
770
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
771
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
772
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
773
|
+
</tr>
|
|
774
|
+
</thead>
|
|
605
775
|
<tbody>
|
|
606
776
|
<tr>
|
|
607
|
-
<td class="tableblock halign-left valign-top"><p class="tableblock">
|
|
608
|
-
<td class="tableblock halign-left valign-top"><p class="tableblock">
|
|
609
|
-
<td class="tableblock halign-left valign-top"><p class="tableblock">
|
|
777
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>callback</code></p></td>
|
|
778
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>(score: number) ⇒ void</code></p></td>
|
|
779
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock">The function to execute when the score changes.</p></td>
|
|
610
780
|
</tr>
|
|
781
|
+
</tbody>
|
|
782
|
+
</table>
|
|
783
|
+
<div class="paragraph">
|
|
784
|
+
<p><strong>Example</strong></p>
|
|
785
|
+
</div>
|
|
786
|
+
<div class="listingblock">
|
|
787
|
+
<div class="content">
|
|
788
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.subscribe((val) => hud.refresh(val));</code></pre>
|
|
789
|
+
</div>
|
|
790
|
+
</div>
|
|
791
|
+
<hr>
|
|
792
|
+
</div>
|
|
793
|
+
<div class="sect3">
|
|
794
|
+
<h4 id="unsubscribecallback-score-number-void-void"><a class="link" href="#unsubscribecallback-score-number-void-void">1.4.2. <code>unsubscribe(callback: (score: number) ⇒ void): void</code></a></h4>
|
|
795
|
+
<div class="paragraph">
|
|
796
|
+
<p>Removes an existing score listener.</p>
|
|
797
|
+
</div>
|
|
798
|
+
<div class="paragraph">
|
|
799
|
+
<p><strong>Parameters</strong></p>
|
|
800
|
+
</div>
|
|
801
|
+
<table class="tableblock frame-all grid-all stretch">
|
|
802
|
+
<colgroup>
|
|
803
|
+
<col style="width: 20%;">
|
|
804
|
+
<col style="width: 20%;">
|
|
805
|
+
<col style="width: 60%;">
|
|
806
|
+
</colgroup>
|
|
807
|
+
<thead>
|
|
611
808
|
<tr>
|
|
612
|
-
<
|
|
613
|
-
<
|
|
614
|
-
<
|
|
809
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
810
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
811
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
812
|
+
</tr>
|
|
813
|
+
</thead>
|
|
814
|
+
<tbody>
|
|
815
|
+
<tr>
|
|
816
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>callback</code></p></td>
|
|
817
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>(score: number) ⇒ void</code></p></td>
|
|
818
|
+
<td class="tableblock halign-left valign-top"><p class="tableblock">The function to remove.</p></td>
|
|
615
819
|
</tr>
|
|
616
820
|
</tbody>
|
|
617
821
|
</table>
|
|
822
|
+
<div class="paragraph">
|
|
823
|
+
<p><strong>Example</strong></p>
|
|
824
|
+
</div>
|
|
825
|
+
<div class="listingblock">
|
|
826
|
+
<div class="content">
|
|
827
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.unsubscribe(onScoreUpdate);</code></pre>
|
|
828
|
+
</div>
|
|
829
|
+
</div>
|
|
618
830
|
<hr>
|
|
619
831
|
</div>
|
|
832
|
+
</div>
|
|
620
833
|
<div class="sect2">
|
|
621
|
-
<h3 id="
|
|
834
|
+
<h3 id="utility-state"><a class="link" href="#utility-state">1.5. Utility & State</a></h3>
|
|
835
|
+
<div class="paragraph">
|
|
836
|
+
<p>Methods for formatting and serialization.</p>
|
|
837
|
+
</div>
|
|
838
|
+
<div class="sect3">
|
|
839
|
+
<h4 id="multiplier-number"><a class="link" href="#multiplier-number">1.5.1. <code>multiplier: number</code></a></h4>
|
|
840
|
+
<div class="paragraph">
|
|
841
|
+
<p>Read and Write property for the current points multiplier. Triggers a <code>MULTIPLIER</code> notification on change.</p>
|
|
842
|
+
</div>
|
|
843
|
+
<div class="paragraph">
|
|
844
|
+
<p><strong>Example</strong></p>
|
|
845
|
+
</div>
|
|
846
|
+
<div class="listingblock">
|
|
847
|
+
<div class="content">
|
|
848
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.multiplier = 2.5; // Enable power-up</code></pre>
|
|
849
|
+
</div>
|
|
850
|
+
</div>
|
|
851
|
+
<hr>
|
|
852
|
+
</div>
|
|
853
|
+
<div class="sect3">
|
|
854
|
+
<h4 id="getformattedscoredigits-number-string"><a class="link" href="#getformattedscoredigits-number-string">1.5.2. <code>getFormattedScore(digits: number): string</code></a></h4>
|
|
622
855
|
<div class="paragraph">
|
|
623
856
|
<p>Returns the score as a padded string suitable for HUD display.</p>
|
|
624
857
|
</div>
|
|
@@ -631,12 +864,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
631
864
|
<col style="width: 20%;">
|
|
632
865
|
<col style="width: 60%;">
|
|
633
866
|
</colgroup>
|
|
634
|
-
<
|
|
867
|
+
<thead>
|
|
635
868
|
<tr>
|
|
636
|
-
<
|
|
637
|
-
<
|
|
638
|
-
<
|
|
869
|
+
<th class="tableblock halign-left valign-top">Name</th>
|
|
870
|
+
<th class="tableblock halign-left valign-top">Type</th>
|
|
871
|
+
<th class="tableblock halign-left valign-top">Description</th>
|
|
639
872
|
</tr>
|
|
873
|
+
</thead>
|
|
874
|
+
<tbody>
|
|
640
875
|
<tr>
|
|
641
876
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>digits</code></p></td>
|
|
642
877
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>number</code></p></td>
|
|
@@ -650,33 +885,66 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
|
|
|
650
885
|
<div class="paragraph">
|
|
651
886
|
<p><code>string</code> - The zero-padded score string.</p>
|
|
652
887
|
</div>
|
|
888
|
+
<div class="paragraph">
|
|
889
|
+
<p><strong>Example</strong></p>
|
|
890
|
+
</div>
|
|
891
|
+
<div class="listingblock">
|
|
892
|
+
<div class="content">
|
|
893
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">const label = core.score.getFormattedScore(6);</code></pre>
|
|
894
|
+
</div>
|
|
895
|
+
</div>
|
|
653
896
|
<hr>
|
|
654
897
|
</div>
|
|
655
|
-
<div class="
|
|
656
|
-
<
|
|
898
|
+
<div class="sect3">
|
|
899
|
+
<h4 id="serialize-string"><a class="link" href="#serialize-string">1.5.3. <code>serialize(): string</code></a></h4>
|
|
657
900
|
<div class="paragraph">
|
|
658
901
|
<p><strong>Behavior</strong></p>
|
|
659
902
|
</div>
|
|
660
903
|
<div class="paragraph">
|
|
661
904
|
<p>Implements <code><a href="../interfaces/Serializable.html">Serializable</a></code>. Packs the current <code>score</code>, <code>level</code>, <code>max_level</code>, <code>multiplier</code>, and <code>highScore</code> into a JSON string to be managed by the active game session.</p>
|
|
662
905
|
</div>
|
|
906
|
+
<div class="paragraph">
|
|
907
|
+
<p><strong>Example</strong></p>
|
|
908
|
+
</div>
|
|
909
|
+
<div class="listingblock">
|
|
910
|
+
<div class="content">
|
|
911
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">const saveData = core.score.serialize();</code></pre>
|
|
912
|
+
</div>
|
|
913
|
+
</div>
|
|
663
914
|
<hr>
|
|
664
915
|
</div>
|
|
665
|
-
<div class="
|
|
666
|
-
<
|
|
916
|
+
<div class="sect3">
|
|
917
|
+
<h4 id="deserializedata-string-void"><a class="link" href="#deserializedata-string-void">1.5.4. <code>deserialize(data: string): void</code></a></h4>
|
|
667
918
|
<div class="paragraph">
|
|
668
919
|
<p><strong>Behavior</strong></p>
|
|
669
920
|
</div>
|
|
670
921
|
<div class="paragraph">
|
|
671
922
|
<p>Implements <code><a href="../interfaces/Serializable.html">Serializable</a></code>. Restores all progress from a saved session string.</p>
|
|
672
923
|
</div>
|
|
924
|
+
<div class="paragraph">
|
|
925
|
+
<p><strong>Example</strong></p>
|
|
926
|
+
</div>
|
|
927
|
+
<div class="listingblock">
|
|
928
|
+
<div class="content">
|
|
929
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">core.score.deserialize(savedState);</code></pre>
|
|
930
|
+
</div>
|
|
931
|
+
</div>
|
|
673
932
|
<hr>
|
|
674
933
|
</div>
|
|
675
|
-
<div class="
|
|
676
|
-
<
|
|
934
|
+
<div class="sect3">
|
|
935
|
+
<h4 id="getdebugdata-recordstring-string-number-boolean"><a class="link" href="#getdebugdata-recordstring-string-number-boolean">1.5.5. <code>getDebugData(): Record<string, string | number | boolean></code></a></h4>
|
|
677
936
|
<div class="paragraph">
|
|
678
937
|
<p>Returns metadata for the real-time debugger.</p>
|
|
679
938
|
</div>
|
|
939
|
+
<div class="paragraph">
|
|
940
|
+
<p><strong>Example</strong></p>
|
|
941
|
+
</div>
|
|
942
|
+
<div class="listingblock">
|
|
943
|
+
<div class="content">
|
|
944
|
+
<pre class="highlightjs highlight"><code class="language-typescript hljs" data-lang="typescript">const debugInfo = core.score.getDebugData();</code></pre>
|
|
945
|
+
</div>
|
|
946
|
+
</div>
|
|
947
|
+
</div>
|
|
680
948
|
</div>
|
|
681
949
|
</div>
|
|
682
950
|
</div>
|