new Manager(surface)
A class which provides the scene management. It is automatically created in constructor of surface .
Parameters:
Name | Type | Description |
---|---|---|
surface |
caph.ui.base.component.Surface |
- Since:
-
- 2.0.0
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager();
Mixes In
Methods
-
add(SceneClass)
-
Adds the scene object by id and sceneClass which user devar fines
Parameters:
Name Type Description sceneID.
String It is for creating Scene by string.
SceneClass
Class - Since:
-
- 2.0.0
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager(); sceneManager.add('main', $class({ $extends: caph.ui.base.Scene }));
-
back(nextStateOfCurrentScene, parameter, callback) → {Boolean}
-
Backs to the last Scene by scene stack.
Parameters:
Name Type Argument Description nextStateOfCurrentScene
Number <optional>
If state is caph.ui.base.Scene.state.INACTIVE, current scene is not removed in the dom tree. So 'onhide' event occurs.
If state is caph.ui.base.Scene.state.READY, current scene is removed in the dom tree. So 'ondetach' event occurs.
If state is caph.ui.base.Scene.state.DESTROY, current scene is removed completely and it can't be reused. 'ondestroy' event occurs.parameter
Object <optional>
Parameter for using in next scene.
callback
function <optional>
The callback function. It will run after changing scene.
- Since:
-
- 2.1.1
Returns:
Result of back.
- Type
- Boolean
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager(); sceneManager.add('main', $class({ $extends: caph.ui.base.Scene })); sceneManager.add('sub', $class({ $extends: caph.ui.base.Scene })); sceneManager.setMainScene('main'); sceneManger.go('sub'); sceneManger.back();
-
getChildren() → {Array.<caph.module.mixins.event.Observer>}
-
Gets the child observers. If the observer has children, this method must be defined in advance. Because when the observer receives a message which is not a bubbling, a message is propagated to child observers.
- Since:
-
- 2.0.0
Returns:
If not defined, default action returns null.
- Type
- Array.<caph.module.mixins.event.Observer>
Example
var Observer = $class({ $extends: caph.ui.base.Component, onclick: function(message) { console.log(message); } }); var observer = new Observer(); var children = observer.getChildren();
-
getParent() → {caph.module.mixins.event.Observer}
-
Gets the parent observer. If the observer has parent, this method must be defined in advance. Because when the observer receives a bubbling message, a message is propagated to parent observer.
- Since:
-
- 2.0.0
Returns:
If not defined, default action returns null.
Example
var Observer = $class({ $extends: caph.ui.base.Component, onclick: function(message) { console.log(message); } }); var observer = new Observer(); var parent = observer.getParent();
-
go(nextStateOfCurrentScene, parameter, callback) → {Boolean}
-
Goes to Scene by id of Scene. scene will be attached. And visibility property of scene will be visible.
Parameters:
Name Type Argument Description targetSceneID.
String It is for go to Scene by string.
nextStateOfCurrentScene
Number <optional>
If state is caph.ui.base.Scene.state.INACTIVE, current scene is not removed in the dom tree. So 'onhide' event occurs.
If state is caph.ui.base.Scene.state.READY, current scene is removed in the dom tree. So 'ondetach' event occurs.
If state is caph.ui.base.Scene.state.DESTROY, current scene is removed completely and it can't be reused. 'ondestroy' event occurs.parameter
Object <optional>
Parameter for using in next scene.
callback
function <optional>
The callback function. It will run after changing scene.
- Since:
-
- 2.1.1
Returns:
Result of go.
- Type
- Boolean
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager(); sceneManager.add('main', $class({ $extends: caph.ui.base.Scene })); sceneManager.add('sub', $class({ $extends: caph.ui.base.Scene })); sceneManager.setMainScene('main'); sceneManger.go('sub');
-
preLoad(callback) → {Boolean}
-
Preloads scene. scene will be attached. And visibility property of scene will be hidden.
Parameters:
Name Type Argument Description targetSceneID.
String It is for pre-loading Scene by string.
callback
function <optional>
The callback function. It will run after completing pre-load.
- Since:
-
- 2.1.1
Returns:
Result of preload.
- Type
- Boolean
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager(); sceneManager.add('main', $class({ $extends: caph.ui.base.Scene })); sceneManager.add('sub', $class({ $extends: caph.ui.base.Scene })); sceneManager.setMainScene('main'); sceneManager.preLoad('sub');
-
setMainScene()
-
sets main scene. It creates main scene and set main scene as property in scene manager. Additionally, it make main scene show
Parameters:
Name Type Description sceneID.
String Id of scene which will be main scene
- Since:
-
- 2.0.0
Example
var surface = new caph.ui.base.component.Surface({size: [100, 100]}); surface._setSceneManager(new SceneManager(surface)); var sceneManager = surface._getSceneManager(); sceneManager.add('main', $class({ $extends: caph.ui.base.Scene })); sceneManager.add('sub', $class({ $extends: caph.ui.base.Scene })); sceneManager.setMainScene('main');