[title: "Credits Class"] ← Back to index

Credits screen

[heading: "Description"]

The Credits state plays the end-of-game credits as a vertically scrolling banner paced by the tempo of a randomly selected background song. It cycles artwork from the local song library as a backdrop. Once the credits finish, the player can press any button to return to the configured state.

[heading: "Key Features"] [list] * Scrollable credits paced by the background song tempo * Background slideshow of song artwork * Plays a random song from the music library [/list] [heading: "Constructor"] [table header] [ Parameter | Type | Description ] [ returnState | string | Game state to return to when credits finish. ] [ returnStateParams | Object | Params forwarded to the return state. ] [/table] [heading: "Properties"] [table header] [ Property | Type | Description ] [ returnState | string | State to return to when credits finish. ] [ returnStateParams | Object | Params forwarded to the return state. ] [ isWaitingForInput | boolean | Whether input is being awaited after the finale. ] [ backgroundInterval | number | Interval in milliseconds between background slides ] [ availableBackgrounds | Array | URLs of backgrounds available for the slideshow. ] [ bpmChanges | ?Array | BPM changes associated with the credits chart ] [ stops | ?Array | Stop timing events associated with the credits chart ] [ startTime | number | Gameplay timestamp used to sync the credits roll ] [ creditsContainer | Phaser.Group | Group holding every scrolling credits line ] [ totalHeight | number | Bottom edge of the credits content used to detect the end ] [ startY | number | Initial scroll position of the credits container ] [ creditsComplete | boolean | Whether the credits roll has finished ] [ backgroundSprite | Phaser.Sprite | Sprite drawing the current credits background ] [ backgroundTimer | ?Phaser.TimerEvent | Timer cycling the background artwork ] [ creditsMusic | HTMLAudioElement | Audio element looping a random song during credits ] [ continueText | Text | Blinking thank-you message shown at the finale ] [/table] [heading: "Methods"] [table header] [ Method | Parameters | Description ] [ init | (returnState, returnStateParams) | Records the return state and initializes credits timing and background data. ] [ create | () | Builds the credits text container, background slideshow, and music. ] [ setupBackground | () | Creates the background sprite and starts the artwork slideshow timer. ] [ startBackgroundMusic | () | Picks a random song with audio and plays it behind the credits. ] [ getSongCredits | () | Collects credit lines for every local song with chart credit metadata. ] [ beatToSec | (beat) | Converts a beat position to seconds using BPM changes and stops. ] [ secToBeat | (sec) | Converts a seconds position to beats using BPM changes and stops. ] [ update | () | Scrolls the credits, syncing speed to the current BPM each frame. ] [ onCreditsComplete | () | Shows the thank-you message and waits for input to leave the screen. ] [ returnToMenu | () | Fades the camera and transitions to the configured return state. ] [ shutdown | () | Removes input handlers and stops credits music and background timers. ] [/table] [heading: "Example Usage (Modding)"] [codeblock javascript] // Modding usage example // Play the credits and return to a chosen state afterward game.state.start("Credits"); // Or specify where to land once the credits complete game.state.start("Credits", true, false, "Title"); [/codeblock] [footer: "© Retora 2026"]