CG.Animation Class
CG.Animation extends CG.Sprite and add support for animations ;o) It needs atlas files with fixed framesizes and with following animation frames. For example you can use Timeline FX generated graphics.
var s = new CG.Animation({
image: '../images/demo.png',
position: new CG.Point(200,200),
startFrame: 5,
endFrame: 6,
width: 10,
height: 20
})
Item Index
Methods
Properties
- alpha
- attachedobject
- bound
- boundingradius
- boundsMode
- clicked
- currentFrame
- delay
- diffpoint
- dragable
- endFrame
- followobject
- followspeed
- followsteps
- frames
- fx
- fy
- height
- hover
- loop
- mapcollision
- offsetx
- offsety
- rotation
- rotationspeed
- startFrame
- status
- tempdelay
- transform
- visible
- width
- xhandle
- xscale
- xspeed
- yhandle
- yscale
- yspeed
Methods
AABB
()
Object
returns the bounds of rotated rectangle
Returns:
returns the calculated bounds
attachObject
()
attach a reference of the given object to this object
checkBound
()
Checks the bound if a boundMode (bounce or slide) is set
checkCollision
-
objects -
callback
checks if there is a collision of the given objects to this object http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/
Parameters:
-
objectsArraya array of objects to check for collision => Sprites, Animations, MapAreas
-
callbackCallbackwhat to do after collision?
follow
()
is there an attached element, this sprite will follow it depending on followspeed or followsteps it follows different
ifAttached
()
if there is a attached object get its position
ifClicked
()
True/false
checks click inside of the rectangle, supports rotation
Returns:
ifMouseOver
()
checks if the mouse/pointer is over the rectangle
init
-
options
Options: image {string} imgpath, image object or atlasimage object to use position {CG.Point} startFrame {number} endFrame {number} width {number} height {number} *
Parameters:
-
optionsObject
Returns:
removeAttachedObject
()
removes the attached object reference
setAttachedOffsetX
()
set the x offset of the attached object to this object
setAttachedOffsetY
()
set the y offset of the attached object to this object
setImage
-
image
initialize image for object. for now => sprite, particle, buffer, bitmap and button use it
Parameters:
-
imageImageimage path, image or atlasimage
updateDiff
()
calculate offset if bound is moving
Properties
alpha
Float
boundsMode
False/string
followobject
Boolean/object
followspeed
Boolean/integer
followsteps
Boolean/integer
rotationspeed
Integer/float
transform
Transform
Transform object for matrix transformation
