An Actor is the root element to a sprite animation using a hierarchy of sprites. It can be moved around by setting the x, y, rotation and scale values and can be flipped horizontally It can automatically moved by setting the motion value. Motion can define x, y, rotation and scale values these are the amount they will change by in 1 second Motion values are in th coordinate system of the root element before scaling An Actor contains layers which are individual sprites in a hierarchy
(Object)
json returned from the spritoon app that describes the nodes and hierarchy of a multi-layered sprite
(Object)
json for spritesheet that describes the positioning of the individual images
(Image)
the actual image described by the frames json
//this.spriteData is the data downloaded from the Spritoon online app niklever.com/spritoon
let actor = new Actor(this.spriteData.sprites[i], this.spriteData.frames, this.spriteImage);
*
An Action defines the motion of sprite layers in an Actor
A channel in an Action is a series of Keys that are attached to sprite. They are used to manipulate the image, x, y, scale, rotation, opacity. After Key one the easing value is used to control the motion
Used to create a frame animation for a multi-framed sprite
(string)
the name of the animation
(object)
an option object that describes the animation.
let options = {
name: "test",
fps: 25, //default is 30 frames per second if not provided
frames: [1,"..",10], //See the parseFrames method for more information
loop: false, //defaults to true if omitted
motion: {x:100, y:-50}, // defaults to 0,0 if omitted
oncomplete: function(){ console.log('animation completed')}, //Called at animation end, called repeatedly for looping animation
}
*
[0,"..",12,"s",0,"..",5]]
".." means count up from current index to value indicated by next element in the array
"r.." means count down from current index to value indicated by next element in the array
"..2" means count up in twos from current index to value indicated by next element in the array
"r..2" means count down in twos from current index to value indicated by next element in the array
"hXXX" means hold the previous index for the number of seconds specified by XXX
"s" means loop start - or 0 if not specified
This method is used by the frames parameter of the options object passed to the constructors
*
(any)
resets the time for this animation to zero and unpauses a paused animation. *
A class to handle sprites with frame animations
(string)
for this sprite
(object)
an options object that passes in the necessary parameters to create the sprite
const options = {
context: context,//A canvas 2d context
image: image,//a sprite sheet
x: 100,
y: 100,
anchor: {0.5, 0.9}, //pivot point halfway across and near bottom of frame from spritesheet
scale: 0.5, //(optional) defaults to 1
opacity: 0.5, //(optional) defaults to 1
rotation: 0.1, //(optional) defaults to 0
backgroundPosition: null, //(optional) defaults to 0,0 allows offset relative to a background location
physicsBody: null, //(optional) defaults to null expects a Matter.Bodies object
anims: anims, //An array of animations probably created using the Spritoon online app
}
let sprite = new AnimSprite('sprite', options);
*
A Sprite is an individual image from the spritesheet
(any)
(object)
an object that describes this sprite
const options{
name: "test",
x: 100,
y: 100,
game: null, //(optional) The game that this sprite is attached to usual in this.sprites array
frameData: frameData, // The frames array from a json file - not used if game is set
image: image, //Spritesheet image - not used if game is set
context: context,
center: null, //if defined it overrides the x,y values and centres the sprite in the game canvas only used if game is defined
frame: "sprite{04}.png", //will replace {04} with index padded to 4 zeroes, {03} would pad to 3 zeroes
index: 1, //The index for the frame image
anchor: {x:0.5, y:0.9}, //(optional - defaults to 0.5,0.5) rotation and scaling center as a ratio of the width and height
scale: 0.5, //(optional - defaults to 1)
opacity: 0.6, //(optional - defaults to 1)
rotation: 0, //in radians
zOrder: 0, (optional - defaults to 0) higher numbers appear infront of lower numbers
// node: used when a sprite node is created by an Actor.
// config: used when a sprite node is created by an Actor
// parent: used when a sprite node is created by an Actor
// children: used when a sprite node is created by an Actor
}
*
(any)
(number)
sets the frame based on the frame name and this index value
*
$param {boolean} restore (optional defaults to true) used for an Actor to define the rest position from which an action happens. If restore is true then the rest position is reset, if restore is false then the current position, rotation, scale and opacity is saved to the rest object. *
(any
= true
)
A Vertex is a simple definition that holds an x and y value and allows you to add and subtract Vertices
A simple class to define a Rectangle
Simple 2d matrix class used when updating sprites that have parents
[a,c,e]
[b,d,f]
[0,0,1]
Class to handle easing functions. Based on Robert Penner's code.
(number)
the value at the start of an easing
(number)
the value to change to.
(number)
the time to elapse in seconds
(number
= 0
)
(optional defaults to 0) pass in Date.now()/1000 if you want times to be relative to now
(number
= 'linear'
)
(optional defaults to linear)
*
easing method that has the same increment throughout the duration, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
easing method that has a slow stop, called by value do not call directly *
easing method that has a slow start and slow end, called by value do not call directly *
easing method that has a slow start, called by value do not call directly *
(any
= this.t
)
(any
= this.b
)
easing method that has a slow stop, called by value do not call directly *
(any
= this.t
)
(any
= this.b
)
easing method that has a slow start and slow end, called by value do not call directly *
Paints text inside a bounding rectangle, if autorender is not passed to the options object then it will be rendered to the canvas immediately
(object)
a canvas 2d context
(string)
the text to draw
(Rect)
a rectangle that defines the bounding shape of the text
(object
= {}
)
an options object that describes the color, alignment, lineHeight, fontSize and font of the text
const options = {
font = "Verdana",
fontSize = 30,
lineHeight = 35,
color = "#ff00aa",
alignment = 'center'
}
const txt = new TextBlock(context, "This is the text to draw\nThis will be on a second line.", new Rect(100,100,200,80), options)
*
renders the TextBlock to the context *
Used by a particle effect
(object)
can contain the following
A simple class to use with an Emitter. Probably not used directly.
(object)
An options object containing the parameters for the particle, see Emitter for details
*
A class to handle preloading assets
(object)
An options object that defines the assets and callbacks for onprogress and oncomplete
*
A class to handle a button
(object
= {}
)
an options object to handle the button
A simple class to handle sound effects and music loops in games
(object)
an options object to handle initialising the class