Requires
- module:engine/polyfill
- module:engine/EventEmitter
- module:engine/Vector
- module:engine/resize
- module:engine/device
Members
-
<static> containerView :HTMLCanvasElement
-
Div that contains game canvas.
Type:
- HTMLCanvasElement
-
<static> game :Game
-
Current activated game.
Note: this may be undefined during switching.
Will be deprecated in future versions.Type:
-
<static> games :object
-
Map of registered games.
Type:
- object
-
<static> pauses :object
-
Map that contains pause state of all kinds of reasons.
See core.pause for more information.Type:
- object
-
<static> resizeFunc :function
-
Current resize function.
Type:
- function
-
<static> resolution :Number
-
Canvas resolution properly choosed based on configs.
Type:
-
<static> rotatePromptElm :HTMLElement
-
Rotate prompt element for mobile devices.
Type:
- HTMLElement
-
<static> rotatePromptVisible :boolean
-
Whether the rotate prompt is visible.
Type:
- boolean
-
<static> sayHello :Boolean
-
Set to
false
to disable version info console output.Type:
- Boolean
-
<static> size :Vector
-
Size of game content.
Type:
-
<static> speed :number
-
Global time speed, whose value is between 0 and 1.
Type:
- number
-
<static> version :string
-
Version text.
Type:
- string
-
<static> view :HTMLCanvasElement
-
Main Canvas element.
Type:
- HTMLCanvasElement
-
<static> viewSize :Vector
-
Size of view (devicePixelRatio independent).
Type:
Methods
-
<static> main(gameCtor, loaderCtor)
-
Main entry.
Parameters:
Name Type Description gameCtor
Game First game class
loaderCtor
Game Asset loader class
-
<static> pause( [reason])
-
Pause the engine with a reason.
Parameters:
Name Type Argument Default Description reason
String <optional>
'untitled' The reason to pause, you have to pass
the same reason when resume from this
pause.Example
import core from 'engine/core'; // Pause when ad is playing core.pause('ad'); // And resume after the ad finished core.resume('ad');
-
<static> resume( [reason] [, force])
-
Unpause the engine.
Parameters:
Name Type Argument Default Description reason
String <optional>
'untitled' Resume from pause tagged with this reason
force
Boolean <optional>
false Whether force to resume
-
<static> setGame(gameCtor [, newInstance] [, param])
-
Switch to a game.
Parameters:
Name Type Argument Default Description gameCtor
Game Game class to be set
newInstance
Boolean <optional>
false Whether create new instance for this game.
param
Object <optional>
{} Parameters to pass to the game(to
Game#awake
)