new Game(canvas, manifest)
Represents a whole game. This class contains all the inputs, outputs, and data for the game.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
external:canvas | The canvas on which to render the game. |
manifest |
object | A key-value set of attributes that describe all the external resources for the game. This references all the images, sounds, fonts, and animations. |
Example
var canvas = document.getElementById("canvas");
var manifest = {
"images": {
"bg": "images/bg.png"
},
"sounds": {
"point": "sounds/point.wav"
},
"fonts": [
"pixelade": {
"embedded-opentype": "pixelade/pixelade-webfont.eot",
"woff": "pixelade/pixelade-webfont.woff",
"truetype": "pixelade/pixelade-webfont.ttf",
"svg": "pixelade/pixelade-webfont.svg#pixeladeregular"
}
],
"animations": {
"player-slide-left": {
"strip": "images/player-slide-anim.png",
"frames": 8,
"msPerFrame": 100
}
}
};
var game = new Splat.Game(canvas, manifest);
Members
accelerometer :Accelerometer
The accelerometer input for the game.
Type:
animations :AnimationLoader
The animation assets for the game.
Type:
fonts :FontLoader
The font assets for the game.
Type:
gamepad :Gamepad
The gamepad input for the game.
Type:
- Gamepad
images :ImageLoader
The image assets for the game.
Type:
keyboard :Keyboard
The keyboard input for the game.
Type:
mouse :Mouse
The mouse input for the game.
Type:
scenes :SceneManager
The scenes for the game.
Type:
sounds :SoundLoader
The sound assets for the game.
Type:
Methods
isChromeApp() → {boolean}
Test if the game is running within a Chrome App.
Returns:
- Type
- boolean
isLoaded() → {boolean}
Test if all the game's assets are loaded.
Returns:
- Type
- boolean
percentLoaded() → {number}
Determine the percent of the game's assets that are loaded. This is useful for drawing a loading bar.
Returns:
A number between 0 and 1
- Type
- number