new app()
A class which has methods for launching application. This class is singleton and make automatically. You can use this just caph.app.[METHOD]
- Since:
-
- 2.0.0
Example
caph.app.initialize(function(surface){
(new UIComponent({
dom : {
innerHTML:'surface object',
style: {
width: 100,
height: 100,
color: 'white',
backgroundColor: 'green'
}
}
})).addTo(surface);
});
caph.app.addScene('main',$class({
$extends : caph.require('ui.base.Scene'),
oncreate: function() {
(new UIComponent({
'dom.innerHTML': 'scene object',
'dom.style' : {
width: 100,
height: 100,
color: 'white',
backgroundColor: 'blue'
}
})).position(100).addTo(this);
}
})).run();
Methods
-
add(sceneID, scene) → {caph.app}
-
Adds a scene definition. This function is enabled once a scene is added.
Parameters:
Name Type Argument Description sceneIDString <optional>
A unique ID represents a scene. If nothing, caph will start with the first added scene.
scenecaph.ui.base.Scene A scene difinition bound with the give scene ID.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.app
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.addScene('main',$class({ $extends : caph.require('ui.base.Scene'), oncreate: function() { (new UIComponent({ 'dom.innerHTML': 'scene object', 'dom.style' : { width: 100, height: 100, color: 'white', backgroundColor: 'blue' } })).position(100).addTo(this); } })).run(); -
initialize(userInitFunc) → {caph.app}
-
Registers a function callback which will be invoked in app's initializing sequence.
Parameters:
Name Type Description userInitFunccallbackInitFunc A function will be invoked in app's initializing sequence.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.app
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.initialize(function(surface){ (new UIComponent({ dom : { innerHTML:'surface object', style: { width: 100, height: 100, color: 'white', backgroundColor: 'green' } } })).addTo(surface); }); -
run(option, sceneID, mount)
-
; Runs caph engine with user's predefined scenes and option. This function is enabled once a scene is added.
Parameters:
Name Type Argument Description optionObject <optional>
option
sceneIDString <optional>
A unique ID represents a scene. If nothing, caph will start with the first added scene.
mountString | HTMLElement | function <optional>
A target DOM Element where caph elements run, a function returning a HTML element, or else a HTML element's id.
- Since:
-
- 2.1.0
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.addScene('main',$class({ $extends : caph.require('ui.base.Scene'), oncreate: function() { (new UIComponent({ 'dom.innerHTML': 'scene object', 'dom.style' : { width: 100, height: 100, color: 'white', backgroundColor: 'blue' } })).position(100).addTo(this); } })).run();