Class Index | File Index

Classes


Class CAAT.Foundation.SpriteImage


Defined in: SpriteImage.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
 
an Array defining the sprite frame sequence
 
This property allows to have multiple different animations defined for one actor.
 
When an animation sequence ends, this callback function will be called.
 
how much Scene time to take before changing an Sprite frame.
 
Number of columns.
 
current animation name
 
pending: refactor -> font scale to a font object.
 
This sprite image image´s width
 
Image to get frames from.
 
map
If the sprite image is defined out of a JSON object (sprite packer for example), this is the subimages original definition map.
 
If the sprite image is defined out of a JSON object (sprite packer for example), this is the subimages calculated definition map.
 
Displacement offset to get the sub image from.
 
Displacement offset to get the sub image from.
 
The actor this sprite image belongs to.
 
When nesting sprite images, this value is the star X position of this sprite image in the parent.
 
When nesting sprite images, this value is the star Y position of this sprite image in the parent.
 
Previous animation frame time.
 
current index of sprite frames array.
 
Number of rows
 
For each element in the sprite image array, its height.
 
For each element in the sprite image array, its size.
 
the current sprite frame
<static>  
CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE
<static>  
CAAT.Foundation.SpriteImage.TR_FIXED_WIDTH_TO_SIZE
<static>  
CAAT.Foundation.SpriteImage.TR_FLIP_ALL
<static>  
CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL
<static>  
CAAT.Foundation.SpriteImage.TR_FLIP_VERTICAL
<static>  
CAAT.Foundation.SpriteImage.TR_NONE
<static>  
CAAT.Foundation.SpriteImage.TR_TILE
 
any of the TR_* constants.
 
This sprite image image´s width
Method Summary
Method Attributes Method Name and Description
<private>  
 
addAnimation(name, array, time, callback)
Add an animation to this sprite image.
 
addElement(key, value)
Add one element to the spriteImage.
 
Create elements as director.getImage values.
 
copy(other)
 
drawText(str, ctx, x, y)
 
 
 
 
 
getMapInfo(index)
 
Get the number of subimages in this compoundImage
 
 
Get a reference to the same image information (rows, columns, image and uv cache) of this SpriteImage.
 
 
 
 
 
initialize(image, rows, columns)
Initialize a grid of subimages out of a given image.
 
initializeAsFontMap(image, chars)
 
 
This method creates a font sprite image based on a proportional font It assumes the font is evenly spaced in the image Example: var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( director.getImage('numbers'), "0123456789" );
 
 
initializeFromMap(image, map)
This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html and creates a map into that image.
 
 
paintAtRect(director, time, x, y, w, h)
 
paintChunk(ctx, dx, dy, x, y, w, h)
 
paintInvertedH(director, time, x, y)
Draws the subimage pointed by imageIndex horizontally inverted.
 
paintInvertedHV(director, time, x, y)
Draws the subimage pointed by imageIndex both horizontal and vertically inverted.
 
paintInvertedV(director, time, x, y)
Draws the subimage pointed by imageIndex vertically inverted.
 
paintN(director, time, x, y)
Draws the subimage pointed by imageIndex.
 
paintScaled(director, time, x, y)
Draws the subimage pointed by imageIndex scaled to the size of w and h.
 
paintScaledWidth(director, time, x, y)
Draws the subimage pointed by imageIndex.
 
paintTile(ctx, index, x, y)
 
paintTiled(director, time, x, y)
Must be used to draw actor background and the actor should have setClip(true) so that the image tiles properly.
 
Start playing a SpriteImage animation.
 
 
 
setAnimationImageIndex(aAnimationImageIndex)
Set the sprite animation images index.
 
Set the elapsed time needed to change the image index.
 
setOffset(x, y)
 
Set horizontal displacement to draw image.
 
Set vertical displacement to draw image.
 
setOwner(actor)
 
 
Draws the sprite image calculated and stored in spriteIndex.
 
setSpriteTransformation(transformation)
Set the transformation to apply to the Sprite image.
 
setUV(uvBuffer, uvIndex)
 
 
Class Detail
CAAT.Foundation.SpriteImage()
Field Detail
animationImageIndex
an Array defining the sprite frame sequence

animationsMap
This property allows to have multiple different animations defined for one actor. see demo31 for a sample.

callback
When an animation sequence ends, this callback function will be called.

changeFPS
how much Scene time to take before changing an Sprite frame.

columns
Number of columns.

currentAnimation
current animation name

fontScale
pending: refactor -> font scale to a font object.

height
This sprite image image´s width

image
Image to get frames from.

map
If the sprite image is defined out of a JSON object (sprite packer for example), this is the subimages original definition map.

mapInfo
If the sprite image is defined out of a JSON object (sprite packer for example), this is the subimages calculated definition map.

offsetX
Displacement offset to get the sub image from. Useful to make images shift.

offsetY
Displacement offset to get the sub image from. Useful to make images shift.

ownerActor
The actor this sprite image belongs to.

parentOffsetX
When nesting sprite images, this value is the star X position of this sprite image in the parent.

parentOffsetY
When nesting sprite images, this value is the star Y position of this sprite image in the parent.

prevAnimationTime
Previous animation frame time.

prevIndex
current index of sprite frames array.

rows
Number of rows

singleHeight
For each element in the sprite image array, its height.

singleWidth
For each element in the sprite image array, its size.

spriteIndex
the current sprite frame

<static> CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE

<static> CAAT.Foundation.SpriteImage.TR_FIXED_WIDTH_TO_SIZE

<static> CAAT.Foundation.SpriteImage.TR_FLIP_ALL

<static> CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL

<static> CAAT.Foundation.SpriteImage.TR_FLIP_VERTICAL

<static> CAAT.Foundation.SpriteImage.TR_NONE

<static> CAAT.Foundation.SpriteImage.TR_TILE

transformation
any of the TR_* constants.

width
This sprite image image´s width
Method Detail
<private> __init()

addAnimation(name, array, time, callback)
Add an animation to this sprite image. An animation is defines by an array of pretend-to-be-played sprite sequence.
Parameters:
name
{string} animation name.
array
{Array} the sprite animation sequence array. It can be defined as number array for Grid-like sprite images or strings for a map-like sprite image.
time
{number} change animation sequence every 'time' ms.
callback
{function({SpriteImage},{string}} a callback function to invoke when the sprite animation sequence has ended.

{*} addElement(key, value)
Add one element to the spriteImage.
Parameters:
key
{string|number} index or sprite identifier.
value
object{ x: {number}, y: {number}, width: {number}, height: {number}, xoffset: {number=}, yoffset: {number=}, xadvance: {number=} }
Returns:
{*}

addElementsAsImages(prefix)
Create elements as director.getImage values. Create as much as elements defined in this sprite image. The elements will be named prefix+
Parameters:
prefix

copy(other)
Parameters:
other

drawText(str, ctx, x, y)
Parameters:
str
ctx
x
y

getColumns()

getCurrentSpriteImageCSSPosition()

getFontData()

getHeight()

getMapInfo(index)
Parameters:
index

{number} getNumImages()
Get the number of subimages in this compoundImage
Returns:
{number}

getOwnerActor()

getRef()
Get a reference to the same image information (rows, columns, image and uv cache) of this SpriteImage. This means that re-initializing this objects image info (that is, calling initialize method) will change all reference's image information at the same time.

getRows()

getWidth()

getWrappedImageHeight()

getWrappedImageWidth()

initialize(image, rows, columns)
Initialize a grid of subimages out of a given image.
Parameters:
image
{HTMLImageElement|Image} an image object.
rows
{number} number of rows.
columns
{number} number of columns
Returns:
this

initializeAsFontMap(image, chars)
Parameters:
image
chars

initializeAsGlyphDesigner(image, map)
Parameters:
image
{Image|HTMLImageElement|Canvas}
map
object with pairs "" : { id : {number}, height : {number}, xoffset : {number}, letter : {string}, yoffset : {number}, width : {number}, xadvance: {number}, y : {number}, x : {number} }

initializeAsMonoTypeFontMap(image, chars)
This method creates a font sprite image based on a proportional font It assumes the font is evenly spaced in the image Example: var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( director.getImage('numbers'), "0123456789" );
Parameters:
image
chars

initializeFromGlyphDesigner(text)
Parameters:
text

initializeFromMap(image, map)
This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html and creates a map into that image.
Parameters:
image
{Image|HTMLImageElement|Canvas} an image
map
{object} the map into the image to define subimages.

initializeFromTexturePackerJSON(image, obj)
Parameters:
image
obj

paintAtRect(director, time, x, y, w, h)
Parameters:
director
time
x
y
w
h

paintChunk(ctx, dx, dy, x, y, w, h)
Parameters:
ctx
dx
dy
x
y
w
h

paintInvertedH(director, time, x, y)
Draws the subimage pointed by imageIndex horizontally inverted.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintInvertedHV(director, time, x, y)
Draws the subimage pointed by imageIndex both horizontal and vertically inverted.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintInvertedV(director, time, x, y)
Draws the subimage pointed by imageIndex vertically inverted.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintN(director, time, x, y)
Draws the subimage pointed by imageIndex.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintScaled(director, time, x, y)
Draws the subimage pointed by imageIndex scaled to the size of w and h.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintScaledWidth(director, time, x, y)
Draws the subimage pointed by imageIndex.
Parameters:
director
{CAAT.Foundation.Director}
time
{number} scene time.
x
{number} x position in canvas to draw the image.
y
{number} y position in canvas to draw the image.
Returns:
this

paintTile(ctx, index, x, y)
Parameters:
ctx
index
x
y

paintTiled(director, time, x, y)
Must be used to draw actor background and the actor should have setClip(true) so that the image tiles properly.
Parameters:
director
time
x
y

playAnimation(name)
Start playing a SpriteImage animation. If it does not exist, nothing happens.
Parameters:
name

resetAnimationTime()

setAnimationEndCallback(f)
Parameters:
f

setAnimationImageIndex(aAnimationImageIndex)
Set the sprite animation images index. This method accepts an array of objects which define indexes to subimages inside this sprite image. If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages with size rows*columns. If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected to be an array of strings which are the names of the subobjects contained in the map object.
Parameters:
aAnimationImageIndex
an array indicating the Sprite's frames.

setChangeFPS(fps)
Set the elapsed time needed to change the image index.
Parameters:
fps
an integer indicating the time in milliseconds to change.
Returns:
this

setOffset(x, y)
Parameters:
x
y

setOffsetX(x)
Set horizontal displacement to draw image. Positive values means drawing the image more to the right.
Parameters:
x
{number}
Returns:
this

setOffsetY(y)
Set vertical displacement to draw image. Positive values means drawing the image more to the bottom.
Parameters:
y
{number}
Returns:
this

setOwner(actor)
Parameters:
actor

setSpriteIndex(index)
Parameters:
index

setSpriteIndexAtTime(time)
Draws the sprite image calculated and stored in spriteIndex.
Parameters:
time
{number} Scene time when the bounding box is to be drawn.

setSpriteTransformation(transformation)
Set the transformation to apply to the Sprite image. Any value of
  • TR_NONE
  • TR_FLIP_HORIZONTAL
  • TR_FLIP_VERTICAL
  • TR_FLIP_ALL
  • Parameters:
    transformation
    an integer indicating one of the previous values.
    Returns:
    this

    setUV(uvBuffer, uvIndex)
    Parameters:
    uvBuffer
    uvIndex

    stringHeight()

    stringWidth(str)
    Parameters:
    str

    Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT)