composer.gotoScene()

Overview

This function is used to transition to a specific scene. When called, the hide event is dispatched to the current scene (if one exists). If a self.view group does not already exist for the specified target scene, the create event will be dispatched to that scene, then the show event will be dispatched.

Syntax

composer.gotoScene( sceneName [, options] )

sceneName (required)

String. The name of the scene to go to. In many cases, this is the name of the scene's Lua file (without the .lua extension).

options (optional)

Table. This table contains several transition-related options such as the effect type, custom parameters, etc. See the Scene Options for the acceptable format of this table.

Scene Options

The options table can contain various options pertaining to the target scene:

effect (optional)

String. Specifies the effect for the scene transition. See Transition Effects for a list of valid options. If no effect is specified, the scene transition will occur instantaneously.

time (optional)

Number. The time duration for the effect, if a valid effect has been specified. Default is 500 milliseconds.

params (optional)

Table. An optional table containing any kind of custom data that should be transferred to the scene. In the specified scene, this data can be accessed via event.params in the create event or show event.

Transition Effects

The following string values are supported for the effect key of the options table: