Module: nav

Handles scene transitions and modal display.
- A modally presented scene can be replaced with a non-modal scene then dismissed to return to original scene.
- A modal can be presented over an existing modal.
Source:

Classes

JumpTrans
MarioTrans
OverTrans
PanTrans
PixelateTrans
PlaxMask

Members

(static, constant) DEFAULT_DUR

Simple fade transition.
- Evoked with 'fade' transition ID.
- Uses `AlphaFilter` to fade contents as a whole rather than individually.
- Default and minimum duration is 0.4 secs. Set the fade duration using colon separator. Eg.`fade:1.0`.
Source:
Example
nav.openScene(myScene, false, 'fade')

Methods

(inner) debugTransStack()

Write to the console a basic outline of child display objects.
Source:

(inner) dismissScene(dismissDataopt)

Dismiss currently presented modal scene.
Parameters:
Name Type Attributes Default Description
dismissData Object <optional>
null Optionally supply an object to be passed to parent scene's `onWillArrive()` method
Source:

(inner) enableInput(enable)

Toggle input for entire stage.
Parameters:
Name Type Description
enable boolean
Source:

(inner) isScenePresentedModally() → {boolean}

Will return if current scene is presented modally.
Source:
Returns:
sceneIsModal
Type
boolean

(inner) isScenePresentedWithTransparentBg() → {boolean}

Will return if current scene has a transparent background.
Source:
Returns:
sceneIsTransparent
Type
boolean

(inner) openScene(sceneID, isModalopt, transIDopt, sceneDataopt) → {boolean}

Transition to a scene.
Parameters:
Name Type Attributes Default Description
sceneID string Scene identifier.
isModal boolean <optional>
false Whether scene should be loaded modally (over the top).
transID TransitionID <optional>
'fade' Transition identifier.
sceneData Object <optional>
null Optional data to be passed to scene.
Source:
Returns:
success.
Type
boolean

(inner) registerTrans(transModule)

Register a custom transition.
Parameters:
Name Type Description
transModule Module
Source:
Example
// In app startup:
import * as CustomTrans from './trans/mytrans.js';
nav.registerTrans(CustomTrans);

(inner) reloadSceneStack(forceopt)

Reload all scene instances with new instances.
Parameters:
Name Type Attributes Default Description
force boolean <optional>
false To ignore the scene's `shouldReloadOnStageResize()`.
Source:

(inner) setScenes(scenes)

Registers all scenes to be loaded.
Parameters:
Name Type Description
scenes Object Scene configuration object
Source:
Example
// app.js
const scenes = {
  home: {class: Home, sceneData: {}, default:true, defaultTransID:'pan:down', defaultBgCol:0xff3300},
  play: {class: Play, sceneData: {}}
}
nav.setScenes(scenes);

Type Definitions

TransitionID

Type:
  • 'fade' | 'over' | 'pan:%direction%' | 'parallax:%direction%' | 'mario:%bgColor%' | 'pixelate'
Source: