Class: AnimationLoader

AnimationLoader

new AnimationLoader(imageLoader, manifest)

Loads and constructs Animations from a manifest. An instance of AnimationLoader is available as Splat.Game#animations.
Parameters:
Name Type Description
imageLoader ImageLoader The ImageLoader used to fetch all external:images.
manifest object The list of Animations to build.
Source:
Example
var manifest = {
		"player-left": { // The Animation's name
			"strip": "img/player-left.png", // The path to a sprite-strip. A sprite strip is multiple frames side-by-side horizontally in a single image.
			"frames": 4, // The number of frames in the Animation
			"msPerFrame": 100 // How many milliseconds to display each frame
		},
		"player-right": {
			"strip": "img/player-left.png", // Re-use the left sprite-strip
			"frames": 4,
			"msPerFrame": 100,
			"flip": "horizontal" // Flip the animation horizontally so we can use the left image for the right.
		},
		"item": { // Create an animation from individual images named "img/item/[0000-0009].png"
			"prefix": "img/item/", // Image filename prefix
			"suffix": ".png", // Image filename suffix
			"padNumberTo": 4, // Number part of image is 4 characters long.
			"frames": 10, // Load 10 separate image files [0-9].
			"msPerFrame": 100,
			"repeatAt": 5, // Loop the animation back at frame 5.
			"rotate": "cw" // Rotate the animation clockwise.
		}
	};
	var imageLoader = new Splat.ImageLoader();
	var animationLoader = new Splat.AnimationLoader(imageLoader, manifest);

Members

imageLoader :ImageLoader

The ImageLoader used to fetch all external:images.
Type:
Source:

manifest :object

The list of Animation metadata.
Type:
  • object
Source:

Methods

allLoaded() → {boolean}

Test if all Animations are loaded.
Source:
Returns:
Type
boolean

get(name) → {Animation}

Fetch a loaded Animation.
Parameters:
Name Type Description
name string The name used to identify the Animation in the AnimationLoader#manifest.
Source:
Returns:
Type
Animation

load(name, info)

Load a single Animation.
Parameters:
Name Type Description
name string The name to store the Animation under. This name will be used to retrieve the Animation from AnimationLoader#get.
info object A single-animation portion of AnimationLoader#manifest.
Source: