Constructor
new Scene(sceneDataopt, psdIDopt, bgColoropt)
Creates a new storymode Scene.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
sceneData |
Object |
<optional> |
null | Optional parameters sent along to the scene construction. |
psdID |
string |
<optional> |
null | The associated PSD, if any. Eg. `mypsd.psd` |
bgColor |
integer |
<optional> |
0x000000 | Solid background color of the scene, used by some transitions. |
- Source:
Example
export default class MyScene extends Scene {
static getSfxResources(){
return {
tap: {path: 'sfx/ui_tap.mp3'},
}
}
constructor(sceneData){
super(sceneData, 'myscene.psd', 0xff3300);
}
didLoad(ev){
super.didLoad(ev);
this.addArt('!_*');
this.ready();
}
shouldReloadOnStageResize(stageW, stageH){
for (let dispoName in this.art){
this.art[dispoName].applyProj()
}
return false;
}
onBtn(btn){
}
onWillArrive(fromModal){
super.onWillArrive(fromModal);
// Perform pre enter transition operations
}
onDidArrive(fromModal){
super.onDidArrive(fromModal);
// Perform post enter transition operations
}
onWillExit(fromModal){
super.onWillExit(fromModal);
// Perform pre exit transition operations
}
onDidExit(fromModal){
super.onDidExit(fromModal);
// Perform post exit transition operations
}
dispose(){
// Perform clean up before instance is destroyed
// Call super method *after* clean up.
super.dispose();
}
}
Extends
- PIXI.Container
Members
(non-null) bgColor :number
The background color of the scene.
Type:
- number
- Source:
(non-null) name :string
The name of the scene instance.
Type:
- string
- Source:
(non-null) psdID :string
The full name of the associated Photoshop document. `ui.addArt()` uses this property to find textures.
Type:
- string
- Source:
sceneData :Object
Any data passed to the scene on creation
Type:
- Object
- Source:
Methods
(static) getSfxResources()
Overwrite to supply a list of audio resources required by the scene. See `sfx` docs for format options.
- Source:
didLoad(parent)
Called after scene is added to the stage. Call `ready()` at the end of any initialisation.
Parameters:
Name | Type | Description |
---|---|---|
parent |
PIXI.Container | Parent container. This should be passed to super when subclassing. |
- Source:
dispose()
Called when scene is about to be destroyed.
When subclassing ensure `super.dispose()` is called after performing clean up.
- Source:
getMarioTransFocusRad(forArrive) → {number}
Overwrite to customise the radius of the `mario` transition spotlight.
Parameters:
Name | Type | Description |
---|---|---|
forArrive |
boolean | Whether for an arrival or exit phase of the transition. |
- Source:
Returns:
radius - Radius of spotlight, in pts.
- Type
- number
getMarioTransPt(forArrive) → {PIXI.Point}
Overwrite to customise the focus point of the `mario` transition animation.
Parameters:
Name | Type | Description |
---|---|---|
forArrive |
boolean | Whether for an arrival or exit phase of the transition. |
- Source:
Returns:
point - Focus point in stage coords (pts),
- Type
- PIXI.Point
mapTxInfo(mappingData, psdIDopt)
Overwrite PSD texture info with supplied values.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
mappingData |
Object | An object representing property paths within `txInfo` with associated values. | ||
psdID |
string |
<optional> |
null | Optionally specify the psd, will default to the `scene.psdID`. |
- Source:
Example
export default class MyScene extends Scene {
constructor(sceneData){
super(sceneData, 'mypsd.psd', 0xff3300);
const hozGfxParams = {
line: {
width: 0,
color: 0x000000,
alpha: 1.0,
alignment: 0
},
fill: {
color: 0x222222,
alpha: 1.0
},
bevel: 0.0
}
// Map textures to any dynamic content
this.mapTxInfo({
'headline.tfParams.text' : 'Welcome text',
'hozgfx.gfxParams' : hozGfxParams
})
}
onBtn(btn)
Captures all clicks for storymode.btn instances added to the scene or its children (up to 2 levels).
Parameters:
Name | Type | Description |
---|---|---|
btn |
storymode.btn | The button that was clicked. |
- Source:
onDidArrive(fromModal)
Lifecycle method: scene arrival transition is complete.
This is a suitable place to add interactive event listeners.
Ensure to call `super.onDidArrive(fromModal)` method when subclassing.
Parameters:
Name | Type | Description |
---|---|---|
fromModal |
boolean | If true then the scene is being presented as the result of a modal being dismissed. |
- Source:
onDidExit(fromModal)
Lifecycle method: scene exit transition is complete.
The scene is no longer visible at this point and cleaning up can be performed.
Ensure to call `super.onDidExit(fromModal)` method when subclassing.
Parameters:
Name | Type | Description |
---|---|---|
fromModal |
boolean | If true then the scene is being temperarily removed to present a modal scene. |
- Source:
onWillArrive(fromModal)
Lifecycle method: scene is added to the stage and transition is about to begin.
This is a suitable place to layout the scene for presentation to the user.
Ensure to call `super.onWillArrive(fromModal)` method when subclassing.
Parameters:
Name | Type | Description |
---|---|---|
fromModal |
boolean | If true then the scene is being presented as the result of a modal being dismissed. |
- Source:
onWillExit(fromModal)
Lifecycle method: scene exit transition is about to begin.
This is a suitable place to remvoe interactive event listeners.
Ensure to call `super.onWillExit(fromModal)` method when subclassing.
Parameters:
Name | Type | Description |
---|---|---|
fromModal |
boolean | If true then the scene is being temperarily removed to present a modal scene. |
- Source:
ready()
To be called by the scene after `didLoad()` when the scene is ready to be presented.
- Source:
shouldReloadOnStageResize(stageWopt, stageHopt) → {boolean}
This method is intended to be overridden to handle stage resize logic.
Return `false` to prevent the `nav` from automatically reloading the scene when a stage resize is detected.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
stageW |
number |
<optional> |
Stage width in points. |
stageH |
number |
<optional> |
Stage height in points. |
- Source:
Returns:
shouldReload - Whether the entire scene should be reloaded with a new one.
- Type
- boolean