Sprite

Package : com.danehansen.display
Class : public class Sprite
Inheritance : Sprite > EventDispatcher > Object
Subclasses : ForwardForward, ForwardRewind, SuperSprite

A sprite class designed to easily create/manipulate animated sprite sheets. This class depends on TweenLite.js which is available at http://greensock.com/ as well as EventDispatcher.js. It is assumed that the sprite sheet will be laid out left to right, top to bottom.

In addition to TweenLite, a certain amount of css styling will have to be applied to the elements to be animated. It is assumed that they will be provided with a background-image, and that the element will have a size applied as well. If the element will be resized or if a retina version of the image will be supplied, then the a background-size property will also have to be applied to the element. For example, if your sprite sheet has 4 columns and 8 rows, your element’s css will read something like this: .

{
	width:220px;
	height:138px;
	background-imgage:url(http://goo.gl/XDwsNz);
	background-size:400% 800%;
}
		

Public Properties

Public Methods

Public Constants

Events

ForwardRewind

Package : com.danehansen.display
Class : public class ForwardRewind
Inheritance : ForwardRewind > Sprite > EventDispatcher > Object

A class designed to quickly make an animated sprite play forward on mouse over, and reverse on mouse out. Great for rollover states on buttons. This class depends on TweenLite.js which is available at http://greensock.com/ as well as Sprite.js and EventDispatcher.js. Instantiating it is almost exactly like its parent class, Sprite, minus the loop argument in the constructor as a ForwardRewind instance is designed to play only forward and back between 0 and 1.

Public Methods

ForwardForward

Package : com.danehansen.display
Class : public class ForwardForward
Inheritance : ForwardForward > Sprite > EventDispatcher > Object

A class designed to quickly make an animated sprite play forward to a given frame on mouse over, and then continue to the end and back to the first frame on mouse out. Great for rollover states on buttons. This class depends on TweenLite.js which is available at http://greensock.com/ as well as Sprite.js and EventDispatcher.js. Instantiating it is almost exactly like its parent class, Sprite, minus the loop argument in the constructor as a ForwardForward instance is designed to utilize a looping sprite sheet.

Public Methods

SuperSprite

Package : com.danehansen.display
Class : public class SuperSprite
Inheritance : SuperSprite > Sprite > EventDispatcher > Object

A sprite class designed for when you need to divide your sprite into several separate images. One reason for doing this would be if your sprite exceeds a total of 5 million pixels. Browsers (especially mobile) tend to have unpredictable behavior when a background image exceeds 5 million pixels. This class depends on TweenLite.js which is available at as well as Sprite.js and EventDispatcher.js.

Public Properties

Public Methods

EXAMPLE 1: BASIC SPRITE

var sprite=new Sprite(document.getElementById("basicSprite"), 4, 30);
sprite.progress(0);
sprite.frame(0);
sprite.progressTo(0);
sprite.frameTo(0);

EXAMPLE 2: LOOPING SPRITE

var sprite=new Sprite(document.getElementById("loopingSprite"), 4, 30, true, 24);
sprite.progress(0);
sprite.frame(0);
sprite.progressTo(0);
sprite.frameTo(0);

EXAMPLE 3: FORWARD/REWIND

var forwardRewind=new ForwardRewind(document.getElementById("forwardRewindSprite"), 4, 30);

EXAMPLE 4: FORWARD/FORWARD

var forwardForward=new ForwardForward(document.getElementById("forwardForwardSprite"), 4, 30, 15);

EXAMPLE 5: SUPER SPRITE

var superSprite=new SuperSprite(
	[new Sprite(document.getElementById("part1"), 4, 16),
	new Sprite(document.getElementById("part2"), 4, 14)], false);