Class

RezScene

RezScene()

Constructor

# new RezScene()

Represents a scene in the Rez game engine. Scenes are containers that manage the flow of cards and content, handling transitions between different parts of the game narrative.

Scene Lifecycle

Scenes follow a defined lifecycle:

  1. start - Scene is initialized and begins playing its initial card
  2. ready - Scene is fully rendered and ready for player interaction
  3. interrupt - Scene is paused for an interlude (optional)
  4. resume - Scene continues after an interlude (optional)
  5. finish - Scene completes and is reset

Layout Modes

Scenes support two layout modes that control how cards are displayed:

  • single - Each new card replaces the previous one (default)
  • stack - Cards stack on top of each other; finished cards flip to show their back

Card Management

Scenes manage the current card and coordinate card transitions:

  • initial_card - The first card played when the scene starts
  • current_card - The currently active card
  • last_card_id - ID of the previously active card
  • Cards are wrapped in RezBlock instances and added to the scene's view layout

Interludes

Scenes can be interrupted for interludes - temporary scene switches that return to the original scene. The game maintains a scene stack for this purpose:

  • interrupt() - Called when an interlude begins
  • resume(params) - Called when returning from an interlude

Event Handlers

Scenes can define event handlers using the on_<event> attribute naming convention:

  • on_start - Called when the scene starts
  • on_ready - Called after the scene is rendered
  • on_start_card - Called when a new card begins
  • on_finish_card - Called when a card finishes
  • on_interrupt - Called when an interlude begins
  • on_resume - Called when returning from an interlude
  • on_finish - Called when the scene ends

View Source rez_scene.js, line 5

Extends

Methods

# addContentToViewLayout(params)

Creates a new content block for the current card and adds it to the scene's view layout

Parameters:
Name Type Description
params object

parameters to pass to the content block

View Source rez_scene.js, line 213

# bindAs() → {string}

Returns the binding identifier for template rendering

View Source rez_scene.js, line 83

"scene"

string

# constructor(id, attributes)

Creates a new scene instance and initializes it to a reset state

Parameters:
Name Type Description
id string

unique identifier for this scene

attributes object

scene attributes from Rez compilation

Overrides:

View Source rez_scene.js, line 50

# createViewLayout() → {RezStackLayout|RezSingleLayout}

Creates a new view layout based on the scene's layout mode. Returns RezStackLayout for stack mode or RezSingleLayout for single mode.

View Source rez_scene.js, line 116

the appropriate layout instance

# current_block() → {RezLayout}

Returns the view layout that manages how content is displayed in this scene

View Source rez_scene.js, line 73

the current view layout for this scene

RezLayout

# finish()

Finishes the scene by completing the current card, triggering the finish event, setting running state to false, and resetting the scene

View Source rez_scene.js, line 282

# finishCurrentCard()

Finishes the currently active card by running its finish event, triggering the scene's finish_card event, and in stack layout mode, flipping the card.

View Source rez_scene.js, line 155

# getViewLayout() → {RezLayout}

Gets or creates the view layout for this scene. The layout is cached and reused.

View Source rez_scene.js, line 105

the view layout instance for this scene

RezLayout

# getViewTemplate(flipped) → {*}

Returns the layout template for rendering this scene. The flipped parameter is ignored since scenes cannot be flipped.

Parameters:
Name Type Description
flipped boolean

ignored for scenes (only cards can be flipped)

View Source rez_scene.js, line 93

the template used to render this scene's layout

*

# interrupt()

Interrupts the current scene execution, typically when switching to an interlude scene. Triggers the scene's interrupt event.

View Source rez_scene.js, line 237

# isStackLayout() → {boolean}

Determines if this scene stacks cards on top of each other (stack mode) or replaces the current card with each new one (single mode)

View Source rez_scene.js, line 62

true if this scene uses stack layout mode

boolean

# playCard(newCard, params)

Transitions to a new card, finishing the current card if any, starting the new one, updating the view, and triggering the card's ready event.

Parameters:
Name Type Description
newCard RezCard

the card instance to play

params object

parameters to pass to the card

View Source rez_scene.js, line 142

# playCardWithId(cardId, params)

Plays a card by looking it up by ID and calling playCard with the card instance

Parameters:
Name Type Description
cardId string

ID of the card to play

params object

parameters to pass to the card

View Source rez_scene.js, line 131

# ready()

Triggers the scene's ready event, indicating the scene is fully initialized and ready for interaction

View Source rez_scene.js, line 273

# reset()

Resets the scene to its initial state, clearing the current card, view layout, and running status

View Source rez_scene.js, line 225

# resume(params)

Resumes the scene after an interlude, triggering the scene's resume event. Note: Card resume/ready events are fired by RezGame.resumePrevScene after the view is updated.

Parameters:
Name Type Description
params object

parameters passed from the interlude scene

View Source rez_scene.js, line 248

# resumeFromLoad()

Resumes the scene after loading from a saved game state. Ensures the current card is properly restored to the view layout.

View Source rez_scene.js, line 198

if no current card is available to resume

Error

# start(params)

Starts the scene by initializing it, triggering the start event, setting the running state, and playing the initial card

Parameters:
Name Type Description
params object

parameters to pass to the scene and initial card

View Source rez_scene.js, line 260

# startNewCard(card, params)

Sets up a new card as the current card, adds it to the view layout, and triggers the appropriate start events.

Parameters:
Name Type Description
card RezCard

the card to start

params object

parameters to pass to the card

View Source rez_scene.js, line 174