GameScoreForm
Methods
- .resultCallback(shell)
- .define(tag, registry)
- .subscribe(context, callback)
Shadow DOM Parts
| Part | Description |
|---|---|
form | The form element |
label | The "Submit your score" label |
input | The name text input |
button | The submit button |
submitted | The confirmation message shown after successful submission |
A name input with a submit button for recording scores to the leaderboard. Integrates with the scores service from the shell and handles the full lifecycle of connecting, submitting, and confirming.
Form States
The form progresses through several states automatically:
- Connecting — While the scores service is fetching a session token, the input and button are disabled and the button reads "Connecting...".
- Ready — Once a token is available, the input and button are enabled and the button reads "Submit".
- Submitting — After the user submits, the button is disabled and reads "Submitting...". A
PendingTaskEventis dispatched to expose the in-flight promise to any external loading coordinator. - Submitted — On success, the form is hidden and replaced with a confirmation message (e.g. "Submitted as ALICE"). The leaderboard is also refreshed.
- Retry — On failure, the button re-enables with "Retry" text.
The form resets to the Ready state each time the game enters the result scene, allowing resubmission on replay.
Events Dispatched
- pending-task
- Dispatched when the score is being submitted. The promise is exposed so external loading coordinators can track completion.
Signal Access
| Signal | Usage |
|---|---|
| Shell signals | Reads scores, scene, and score signals for token status, score submission, form reset, and submission value |
Usage
<div when-some-scene="result" data-overlay>
<game-result-stat label="Score"></game-result-stat>
<game-score-form></game-score-form>
<game-leaderboard></game-leaderboard>
<button commandfor="game" command="--restart">Play Again</button>
</div>
See the Scoring guide for how to configure the score service.