# 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:
- start - Scene is initialized and begins playing its initial card
- ready - Scene is fully rendered and ready for player interaction
- interrupt - Scene is paused for an interlude (optional)
- resume - Scene continues after an interlude (optional)
- 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 startscurrent_card- The currently active cardlast_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 beginsresume(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 startson_ready- Called after the scene is renderedon_start_card- Called when a new card beginson_finish_card- Called when a card finisheson_interrupt- Called when an interlude beginson_resume- Called when returning from an interludeon_finish- Called when the scene ends
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 |
# 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:
# 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.
the appropriate layout instance
# current_block() → {RezLayout}
Returns the view layout that manages how content is displayed in this scene
the current view layout for this scene
# finish()
Finishes the scene by completing the current card, triggering the finish event, setting running state to false, and resetting the scene
# 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.
# getViewLayout() → {RezLayout}
Gets or creates the view layout for this scene. The layout is cached and reused.
the view layout instance for this scene
# 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) |
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.
# 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)
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 |
# 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 |
# ready()
Triggers the scene's ready event, indicating the scene is fully initialized and ready for interaction
# reset()
Resets the scene to its initial state, clearing the current card, view layout, and running status
# 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 |
# resumeFromLoad()
Resumes the scene after loading from a saved game state. Ensures the current card is properly restored to the view layout.
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 |