Class: Game

Splat. Game

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.
Source:
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:
Source:

animations :AnimationLoader

The animation assets for the game.
Type:
Source:

fonts :FontLoader

The font assets for the game.
Type:
Source:

gamepad :Gamepad

The gamepad input for the game.
Type:
  • Gamepad
Source:

images :ImageLoader

The image assets for the game.
Type:
Source:

keyboard :Keyboard

The keyboard input for the game.
Type:
Source:

mouse :Mouse

The mouse input for the game.
Type:
Source:

scenes :SceneManager

The scenes for the game.
Type:
Source:

sounds :SoundLoader

The sound assets for the game.
Type:
Source:

Methods

isChromeApp() → {boolean}

Test if the game is running within a Chrome App.
Source:
Returns:
Type
boolean

isLoaded() → {boolean}

Test if all the game's assets are loaded.
Source:
Returns:
Type
boolean

percentLoaded() → {number}

Determine the percent of the game's assets that are loaded. This is useful for drawing a loading bar.
Source:
Returns:
A number between 0 and 1
Type
number