animated, moving image that is automatically moved, animated, and drawn More...
Public Member Functions | |
addFramesImage (Image image, int startingFrame=start_FromFirstFrame, int numFrames=all_Frames) | |
add one or more frames to the sprite from an Image or ImageStrip More... | |
changeFramesImage (Image oldImage, Image newImage) | |
replace all references in the sprite to one image with another image More... | |
deserialize (Deserializer deserializer) | |
update this sprite from the data in stream More... | |
Sprite | disableCollisions () |
stop checking for collisions with this sprite More... | |
disconnect (Sprite otherSprite=ALL_SPRITES) | |
remove all connections (joints) to another sprite More... | |
Sprite | enableCollisions (int collisionType=collide_AlphaChannel) |
start checking for collisions with this sprite More... | |
fadeIn (int msDuration, int easing=linearTween) | |
fade in to full opacity over time More... | |
fadeOut (int msDuration, int easing=linearTween) | |
fade out full transparency over time More... | |
fadeTo (number targetOpacity, int msDuration, int easing=linearTween) | |
fade in to a specific opacity over time More... | |
CpConstraint | gear (Sprite otherSprite, number gearRatio, number initialAngle=0, number breakingForce=0) |
join two sprites as if they were geared together (Chipmunk Physics Only) More... | |
number | getCollideGroup () |
see which collide group this sprite is part of (Chipmunk Physics Only) More... | |
number | getCollisionRadius () |
get the collision radius for this sprite More... | |
number | getCurrentFrame () |
which frame of animation the sprite is currently showing More... | |
number | getElasticity () |
get the elasticity for this sprite's collisions More... | |
Offset | getFrameCenterOffset (Image image=null, int frameNum=0) |
get the offset to the center-point from the true image center for a given frame More... | |
number | getFrameCount () |
get number of frames of animation for this sprite More... | |
RotatedRect | getFrameRotatedBounds (int frameNum=-1) |
get the bounds of the sprite, including rotation, for a given frame, in layer coordinates. If no frameNum is passed in, or the frame is not present, the bounds of the current frame are returned. More... | |
number | getFriction () |
get the friction used for movement calculations for this sprite (Chipmunk Physics Only) More... | |
SpriteLayer | getLayer () |
get the layer that contains this sprite More... | |
number | getMouseDetectMode () |
number | getMyClassTag () |
returns class tag for Sprite, used for serialization More... | |
number | getOpacity () |
get the level of opacity for this sprite More... | |
uint | getSerializedSize (Serializer serializer) |
get the bytes needed to serialize the layer More... | |
boolean | getWantsAnimEndEvents () |
boolean | getWantsAnimLoopEvents () |
boolean | getWantsClickEvents () |
boolean | getWantsCollideWallEvents () |
boolean | getWantsMouseOverEvents () |
boolean | getWantsOffscreenEvents () |
int | getZOrder () |
get the z-order of this sprite in the layer it belongs to More... | |
CpConstraint | grooveJoint (Offset grooveStart, Offset grooveEnd, Sprite otherSprite, Offset otherAnchor, number breakingForce=0) |
join groove on this sprite to an anchor point on another (Chipmunk Physics Only) More... | |
boolean | hasAnimation (int animationId) |
check if a sprite has a particular SCML animation by ID More... | |
boolean | hasAnimation (string animationName) |
check if a sprite has a particular SCML animation by name More... | |
boolean | isBehind (Sprite sprite) |
returns true if this sprite will be drawn before the given sprite More... | |
makeJointBreakable (CpConstraint joint, number breakingForce) | |
set or change force at which the joint between sprites will break (Chipmunk Physics Only) More... | |
makeJointUnbreakable (CpConstraint joint) | |
make the joint impossible to break (Chipmunk Physics Only) More... | |
Sprite | makeStatic () |
make this sprite unaffected by physics (Chipmunk Physics Only) More... | |
CpConstraint | motor (Sprite otherSprite, number spin, number maxTorque=INFINITY) |
keep spin of another sprite at a constant rate compared to this one (Chipmunk Physics Only) More... | |
Sprite | moveBehind (Sprite sprite) |
make this sprite be drawn before another sprite (visually behind) More... | |
Sprite | moveInFrontOf (Sprite sprite) |
make this sprite be drawn just after another sprite (visually in front of) More... | |
Sprite | moveToBack () |
put this sprite behind all others in its layer More... | |
Sprite | moveToFront () |
put this sprite in front of all others in its layer More... | |
offsetFrameCenters (int offsetX, int offsetY, Image image=null, int startingFrame=start_FromFirstFrame, int numFrames=all_Frames) | |
change the center of rotation for the sprite More... | |
IEventHandler | on (int eventCode, function func) |
set event handler for all different sprite events More... | |
IEventHandler | onAnimationEnd (function func) |
set event handler for sprite animation end events More... | |
IEventHandler | onAnimationLoop (function func) |
set event handler for sprite animation loop events More... | |
IEventHandler | onCollideSprite (function func) |
set event handler for sprite-to-sprite collision events More... | |
IEventHandler | onCollideWall (function func) |
set event handler for sprite-wall collision events More... | |
IEventHandler | onExitLayer (function func) |
set event handler for sprite out of bounds event More... | |
IEventHandler | onFadeComplete (function func) |
set event handler for sprite fade event More... | |
IEventHandler | onFadeInComplete (function func) |
set event handler for sprite fade in event More... | |
IEventHandler | onFadeOutComplete (function func) |
set event handler for sprite fade out event More... | |
IEventHandler | onMouseClick (function func) |
set event handler for tap or mouse click in this sprite More... | |
IEventHandler | onMouseDown (function func) |
set event handler for finger down or mouse down in this sprite More... | |
IEventHandler | onMouseEnter (function func) |
set event handler for mouse pointer entering this sprite (NOT IMPLEMENTED) More... | |
IEventHandler | onMouseLeave (function func) |
set event handler for mouse pointer leaving this sprite (NOT IMPLEMENTED) More... | |
IEventHandler | onMouseUp (function func) |
set event handler for finger up or mouse up in this sprite More... | |
IEventHandler | onOffscreen (function func) |
set event handler for sprite offscreen event More... | |
IEventHandler | onOnscreen (function func) |
set event handler for sprite onscreen event More... | |
CpConstraint | pinJoint (Offset anchor, Sprite otherSprite, Offset otherAnchor, number breakingForce=0) |
pin sprites together at a particular anchor point (offset from center) on each (Chipmunk Physics Only) More... | |
CpConstraint | pivotJoint (Sprite otherSprite, Point pivot, number breakingForce=0) |
join sprites together at a particular location in layer coordinates (Chipmunk Physics Only) More... | |
CpConstraint | ratchet (Sprite otherSprite, number rachetInterval, number phase, number breakingForce=0) |
join two sprites rotation with a ratchet mechanism (Chipmunk Physics Only) More... | |
removeJoint (CpConstraint joint) | |
remove a joint between two sprites (Chipmunk Physics Only) More... | |
CpConstraint | rotaryLimit (Sprite otherSprite, number minAngle, number maxAngle, number breakingForce=0) |
limit the angle another sprite can have relative to this one (Chipmunk Physics Only) More... | |
CpConstraint | rotarySpring (Sprite otherSprite, number restAngle, number stiffness, number damping, number breakingForce=0) |
keep sprites at a particular angle relative to one another via a rotary spring (Chipmunk Physics Only) More... | |
serialize (Serializer serializer) | |
serialize this sprite into a data stream More... | |
Sprite | setCollideGroup (int group) |
set the collide group this sprite is part of (Chipmunk Physics Only) More... | |
setCollisionHelper (ISpriteCollideHelper helper) | |
set a helper to filter out some collisions for this sprite More... | |
Sprite | setCollisionRadius (number pixelRadius) |
set the radius of the collision boundary circle of the sprite More... | |
setDrawHelper (ISpriteDrawHelper helper) | |
set a pre-draw helper for custom sprite drawing More... | |
Sprite | setElasticity (number elasticity) |
Sprite | setEntityScale (number xScale, number yScale) |
Sprite | setFrame (int frame) |
Sprite | setMouseDetectMode (int collisionType=collide_BoundingBox) |
Sprite | setOpacity (number opacity) |
setPostDrawHelper (ISpriteDrawHelper helper) | |
Sprite | setWantsAnimEndEvents (boolean wantsThem=true) |
Sprite | setWantsAnimLoopEvents (boolean wantsThem=true) |
Sprite | setWantsClickEvents (boolean wantsThem=true) |
Sprite | setWantsCollideWallEvents (boolean wantsThem=true) |
Sprite | setWantsMouseOverEvents (boolean wantsThem=true) |
Sprite | setWantsOffscreenEvents (boolean wantsThem=true) |
CpConstraint | slideJoint (Offset anchor, Sprite otherSprite, Offset otherAnchor, number minDist, number maxDist, number breakingForce=0) |
join sprites together via a slider between anchor points that has a min/max distance (Chipmunk Physics Only) More... | |
CpConstraint | springJoint (Offset anchor, Sprite otherSprite, Offset otherAnchor, number restLength, number stiffness, number damping, number breakingForce=0) |
join sprites together via a spring between anchor points (Chipmunk Physics Only) More... | |
startAnimation (int animationId) | |
startAnimation (string animationName) | |
startFrameAnimation (number fps, int startingFrame=start_FromFirstFrame, int numFrames=all_Frames, int animateFlags=animate_Looping) | |
stopFrameAnimation () | |
useCollisionMask (Image frameImage, Image maskImage) | |
Public Member Functions inherited from Animated | |
accelerate (number deltaSpeed, int msDuration=duration_Instantaneous, int easing=linearTween) | |
change the object's speed over time More... | |
accelerateTo (number speed, int msDuration=duration_Instantaneous, int easing=linearTween) | |
change the object's speed to a particular value over time More... | |
addAnimationHelper (IAnimationHelper helper) | |
setup a helper to handle custom animation More... | |
boolean | animate (int msElapsed) |
animate based on the passage of time More... | |
applyForce (Vector force, int msDuration=duration_Instantaneous) | |
apply a force to the object over time More... | |
applyTorque (number forceSpin, int msDuration=duration_Instantaneous) | |
apply torque to the object over time More... | |
changeCenter (Offset offset, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
shift the center point of the object over time More... | |
changeCenterTo (Offset offset, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
shift the center point of the object to a particular offset from true center over time More... | |
clearAnimationHelpers () | |
remove all previously added animation helpers More... | |
Rect | getBoundingBox () |
get the rectangle that completely encloses the object More... | |
Offset | getCenterOffset () |
get the current offset of the center relative to the true center point More... | |
number | getHeight () |
get height of the object More... | |
Point | getLocation () |
get the position of the object More... | |
number | getMass () |
get the mass of the object More... | |
number | getMoveFriction () |
get the amount of friction for movement More... | |
number | getMovementDirectionInRadians () |
get the direction the object is moving More... | |
RotatedRect | getRotatedBounds () |
get the bounds with rotation More... | |
number | getRotation () |
get how much the object is rotated More... | |
number | getSizeFriction () |
get the friction applied to size changes (growing or shrinking) More... | |
number | getSpeed () |
get how fast the object is moving in pixels/sec More... | |
number | getSpin () |
get how fast the object is spinning in radians per second More... | |
number | getSpinFriction () |
get the friction applied toward spinning More... | |
Vector | getVelocity () |
get the vector that expresses magnitude and direction of the object's movement in pixels/sec More... | |
number | getWidth () |
get the width of the object More... | |
grow (number factor, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
change size of the object by a factor over time More... | |
move (Offset delta, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
move the object by a certain amount over time More... | |
moveTo (Point where, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
move the object to a particular location over time More... | |
removeAnimationHelper (IAnimationHelper helper) | |
remove a specific animation helper More... | |
resize (number deltaWidth, number deltaHeight, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
change the size of an object by a given amount over time More... | |
resizeTo (number width, number height, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
resize the object to a specific size over time More... | |
rotate (number radians, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
rotate the object by a specific amount over time More... | |
rotateTo (number radiansRotation, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
rotate the object to face a particular direction over time More... | |
Animated | setCenterOffset (Offset inCenterOffset) |
set the offset of the center point relative to the true center More... | |
Animated | setFriction (number frictionCoefficient) |
set friction for movement, rotation and resizing all at once More... | |
Animated | setHeight (number inHeight) |
set the object's height More... | |
Animated | setLocation (Point inLocation) |
place the object at a particular location More... | |
Animated | setMass (number inMass) |
set the object's mass, used when forces are applied More... | |
Animated | setMoveFriction (number inMoveFriction) |
set the object's friction for movement More... | |
Animated | setRotation (number inRotation) |
set the direction the object is facing in radians More... | |
Animated | setSize (number width, number height) |
set the size of the object More... | |
Animated | setSizeFriction (number inSizeFriction) |
set the friction applied for object resizing More... | |
Animated | setSpeed (number inSpeed) |
set the speed the object is moving in its current direction of motion More... | |
Animated | setSpin (number inSpin) |
set the rate at which the object is spinning, in radians/sec More... | |
Animated | setSpinFriction (number inSpinFriction) |
set the friction the object faces for spinning More... | |
Animated | setVelocity (Vector deltaPerSec) |
set the speed and direction the object is moving More... | |
Animated | setVelocity (number deltaXPerSec, number deltaYPerSec) |
set the speed and direction the object is moving More... | |
Animated | setVelocityInRadians (number speed, number direction) |
set the speed and direction the object is moving More... | |
Animated | setWidth (number inWidth) |
set the width of the object More... | |
startGrowing (number amountPerSecond) | |
set the growth rate of the object in pixels/sec More... | |
startStretching (number widthPerSecond, number heightPerSecond) | |
set the growth rate of the object in pixels/sec, with varied rates for width and height More... | |
stopAllForces () | |
remove all forces that were acting on the object (except friction) More... | |
stopGrowing () | |
stop any size change More... | |
stopMoving () | |
stop any movement the object was doing (except spinning) More... | |
stopSpinning () | |
stop any spinning the object was doing More... | |
stopStretching () | |
stop any stretching the object was doing More... | |
stretch (number widthFactor, number heightFactor, int msDuration=duration_Instantaneous, int easing=easeInOutQuad) | |
change the dimensions of the object over time More... | |
Animated | wait (int msDuration) |
wait before beginning the next animation call that operates over time More... | |
Public Member Functions inherited from EventEmitter | |
addHandler (IEventHandler inHandler, int inEventType=all_events) | |
add a new handler for some event type, or for all events if no type specified. More... | |
blockEvent (int inEventType) | |
temporarily ignore all events of a particular type. More... | |
clear () | |
remove all handlers More... | |
removeHandler (IEventHandler inHandler, int inEventType=all_events) | |
remove a handler for some event type, or for all events (see note) if no type specified. More... | |
unblockEvent (int inEventType) | |
stop ignoring events of a particular type More... | |
Additional Inherited Members | |
Related Functions inherited from ISerializable | |
registerSerializableClass | |
register a particular class as implementing ISerializable interface More... | |
animated, moving image that is automatically moved, animated, and drawn
Things that happen to a sprite that might require intervention, such as collisions, completed animations, going offscreen, etc... will generate events. Events generated by sprites first go to any handlers attached directly to the Sprite, then propagate up to the SpriteLayer and then the EventManager until they are handled.
You can add helper functions or classes to do specialized animation behavior, prefilter collisions, and add visual effects during drawing.
addFramesImage | ( | Image | image, |
int | startingFrame = start_FromFirstFrame , |
||
int | numFrames = all_Frames |
||
) |
add one or more frames to the sprite from an Image or ImageStrip
replace all references in the sprite to one image with another image
deserialize | ( | Deserializer | deserializer | ) |
update this sprite from the data in stream
disableCollisions | ( | ) |
stop checking for collisions with this sprite
disconnect | ( | Sprite | otherSprite = ALL_SPRITES | ) |
remove all connections (joints) to another sprite
If otherSprite is not passed in, it will remove all joints for this sprite, regardless of what sprite they are connected to.
enableCollisions | ( | int | collisionType = collide_AlphaChannel | ) |
start checking for collisions with this sprite
Collision Types are:
fadeIn | ( | int | msDuration, |
int | easing = linearTween |
||
) |
fade in to full opacity over time
Generates an eventType_SpriteAnimate action_FadeInComplete event when done.
mySprite.fadeIn(1000); // immediately start to fade in over the next second myOtherSprite.wait(2000).fadeIn(1000); // wait 2 seconds, then fade in
fadeOut | ( | int | msDuration, |
int | easing = linearTween |
||
) |
fade out full transparency over time
Generates an eventType_SpriteAnimate action_FadeOutComplete event when done.
mySprite.fadeOut(1000); // immediately start to fade out over the next second myOtherSprite.wait(2000).fadeOut(1000); // wait 2 seconds, then fade out
fadeTo | ( | number | targetOpacity, |
int | msDuration, | ||
int | easing = linearTween |
||
) |
fade in to a specific opacity over time
Generates an eventType_SpriteAnimate action_FadeComplete event when done.
mySprite.fadeTo(0.5, 1000); // immediately start to fade to 50% opacity over the next second myOtherSprite.wait(2000).fadeTo(0.5, 1000); // wait 2 seconds, then fade to 50% opacity
gear | ( | Sprite | otherSprite, |
number | gearRatio, | ||
number | initialAngle = 0 , |
||
number | breakingForce = 0 |
||
) |
join two sprites as if they were geared together (Chipmunk Physics Only)
Whenever this sprite spins, it will force the other to spin the same amount (adjusted by the gear ratio).
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of rotational force (torque) is applied to the joint.
getCollideGroup | ( | ) |
see which collide group this sprite is part of (Chipmunk Physics Only)
Items in the same collide group do not collide with one another. Sprites that are connected with joints are automatically assigned to the same collide group.
getCollisionRadius | ( | ) |
get the collision radius for this sprite
getCurrentFrame | ( | ) |
which frame of animation the sprite is currently showing
getElasticity | ( | ) |
get the elasticity for this sprite's collisions
getFrameCenterOffset | ( | Image | image = null , |
int | frameNum = 0 |
||
) |
get the offset to the center-point from the true image center for a given frame
If image is passed in, then frameNum is for that the Nth frame of that image, otherwise frameNum indicates which frame for the sprite
getFrameCount | ( | ) |
get number of frames of animation for this sprite
getFrameRotatedBounds | ( | int | frameNum = -1 | ) |
get the bounds of the sprite, including rotation, for a given frame, in layer coordinates. If no frameNum is passed in, or the frame is not present, the bounds of the current frame are returned.
getFriction | ( | ) |
get the friction used for movement calculations for this sprite (Chipmunk Physics Only)
getLayer | ( | ) |
get the layer that contains this sprite
number getMouseDetectMode | ( | ) |
getMyClassTag | ( | ) |
returns class tag for Sprite, used for serialization
getOpacity | ( | ) |
get the level of opacity for this sprite
getSerializedSize | ( | Serializer | serializer | ) |
get the bytes needed to serialize the layer
Takes into account the serialization mode of the layer it is in
boolean getWantsAnimEndEvents | ( | ) |
boolean getWantsAnimLoopEvents | ( | ) |
boolean getWantsClickEvents | ( | ) |
boolean getWantsCollideWallEvents | ( | ) |
boolean getWantsMouseOverEvents | ( | ) |
boolean getWantsOffscreenEvents | ( | ) |
getZOrder | ( | ) |
get the z-order of this sprite in the layer it belongs to
0 means furthest back (drawn first)
grooveJoint | ( | Offset | grooveStart, |
Offset | grooveEnd, | ||
Sprite | otherSprite, | ||
Offset | otherAnchor, | ||
number | breakingForce = 0 |
||
) |
join groove on this sprite to an anchor point on another (Chipmunk Physics Only)
optional breaking force at which the joint (and and any other connections to that sprite) are broken
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of force is applied to the joint.
hasAnimation | ( | int | animationId | ) |
check if a sprite has a particular SCML animation by ID
hasAnimation | ( | string | animationName | ) |
check if a sprite has a particular SCML animation by name
isBehind | ( | Sprite | sprite | ) |
returns true if this sprite will be drawn before the given sprite
makeJointBreakable | ( | CpConstraint | joint, |
number | breakingForce | ||
) |
set or change force at which the joint between sprites will break (Chipmunk Physics Only)
makeJointUnbreakable | ( | CpConstraint | joint | ) |
make the joint impossible to break (Chipmunk Physics Only)
makeStatic | ( | ) |
make this sprite unaffected by physics (Chipmunk Physics Only)
This sprite becomes a static body that isn't affected by physics, though non-static objects can collide with it. This would be used for walls or platforms.
motor | ( | Sprite | otherSprite, |
number | spin, | ||
number | maxTorque = INFINITY |
||
) |
keep spin of another sprite at a constant rate compared to this one (Chipmunk Physics Only)
moveBehind | ( | Sprite | sprite | ) |
make this sprite be drawn before another sprite (visually behind)
moveInFrontOf | ( | Sprite | sprite | ) |
make this sprite be drawn just after another sprite (visually in front of)
moveToBack | ( | ) |
put this sprite behind all others in its layer
moveToFront | ( | ) |
put this sprite in front of all others in its layer
offsetFrameCenters | ( | int | offsetX, |
int | offsetY, | ||
Image | image = null , |
||
int | startingFrame = start_FromFirstFrame , |
||
int | numFrames = all_Frames |
||
) |
change the center of rotation for the sprite
Normally a sprite rotates around it's visual center, that is, the center-point of each frame of animation. This lets you shift that center of rotation, for all frames, on a per Image basis, or on a frame by frame basis.
offsetX | the horizontal offset from true center for the new center-point |
offsetY | the vertical offset from the true center for the new center-point |
image | if passed, only change the center points for frames using that image, and make frame numbers relative to the Image frames. |
startingFrame | if passed, only change frames starting at a particular index in the frame list (or Image frame list if image also passed) |
numFrames | only change this many frames |
on | ( | int | eventCode, |
function | func | ||
) |
set event handler for all different sprite events
onAnimationEnd | ( | function | func | ) |
set event handler for sprite animation end events
These happen when this sprite finishes a particular frame animation sequence, but only if setWantsAnimEndEvents(true) was called
onAnimationLoop | ( | function | func | ) |
set event handler for sprite animation loop events
These happen when this sprite finishes a particular frame animation sequence and is restarting it because it is set to loop, but only if setWantsAnimLoopEvents(true) was called.
onCollideSprite | ( | function | func | ) |
set event handler for sprite-to-sprite collision events
The happens whenever this sprite collides with another sprite, but only if enableCollisions() or setCollisionRadius() was called
onCollideWall | ( | function | func | ) |
set event handler for sprite-wall collision events
This happens whenever this sprite collides with the boundaries of the layer, but only if setWantsCollideWallEvents(true) was called.
onExitLayer | ( | function | func | ) |
set event handler for sprite out of bounds event
These happen whenever this sprite moves completely outside the boundaries of the layer, but only if setWantsCollideWallEvents(true) was called.
onFadeComplete | ( | function | func | ) |
set event handler for sprite fade event
This happens whenever this sprite completes a fade over time done by fadeTo()
onFadeInComplete | ( | function | func | ) |
set event handler for sprite fade in event
This happens whenever this sprite completes a fade in over time done by a call to fadeIn()
onFadeOutComplete | ( | function | func | ) |
set event handler for sprite fade out event
This happens whenever this sprite completes a fade out over time done by a call to fadeOut()
onMouseClick | ( | function | func | ) |
set event handler for tap or mouse click in this sprite
Only works if you first call setWantsClickEvents(true).
onMouseDown | ( | function | func | ) |
set event handler for finger down or mouse down in this sprite
Only works if you first call setWantsClickEvents(true).
onMouseEnter | ( | function | func | ) |
set event handler for mouse pointer entering this sprite (NOT IMPLEMENTED)
Only works if you first call setWantsMouseOverEvents(true).
onMouseLeave | ( | function | func | ) |
set event handler for mouse pointer leaving this sprite (NOT IMPLEMENTED)
Only works if you first call setWantsMouseOverEvents(true).
onMouseUp | ( | function | func | ) |
set event handler for finger up or mouse up in this sprite
Only works if you first call setWantsClickEvents(true).
onOffscreen | ( | function | func | ) |
set event handler for sprite offscreen event
This happens whenever this sprite moves completely outside the visible area of the port the layer is being rendered in, but only if you first call setWantsOffscreenEvents(true)
onOnscreen | ( | function | func | ) |
set event handler for sprite onscreen event
This happens whenever this sprite moves into the visible area of the port the layer is being rendered into, but only if you first call setWantsOffscreenEvents(true)
pin sprites together at a particular anchor point (offset from center) on each (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of force is applied to the joint.
join sprites together at a particular location in layer coordinates (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of force is applied to the joint.
ratchet | ( | Sprite | otherSprite, |
number | rachetInterval, | ||
number | phase, | ||
number | breakingForce = 0 |
||
) |
join two sprites rotation with a ratchet mechanism (Chipmunk Physics Only)
like a socket wrench. ratchetInterval is the distance between “clicks”, phase is the initial angular offset to use when deciding where the ratchet angles are.
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of rotational force (torque) is applied to the joint.
removeJoint | ( | CpConstraint | joint | ) |
remove a joint between two sprites (Chipmunk Physics Only)
rotaryLimit | ( | Sprite | otherSprite, |
number | minAngle, | ||
number | maxAngle, | ||
number | breakingForce = 0 |
||
) |
limit the angle another sprite can have relative to this one (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of rotational force (torque) is applied to the joint.
rotarySpring | ( | Sprite | otherSprite, |
number | restAngle, | ||
number | stiffness, | ||
number | damping, | ||
number | breakingForce = 0 |
||
) |
keep sprites at a particular angle relative to one another via a rotary spring (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of rotational force (torque) is applied to the joint.
serialize | ( | Serializer | serializer | ) |
serialize this sprite into a data stream
setCollideGroup | ( | int | group | ) |
set the collide group this sprite is part of (Chipmunk Physics Only)
Items in the same collide group do not collide with one another. Sprites that are connected with joints are automatically assigned to the same collide group.
setCollisionHelper | ( | ISpriteCollideHelper | helper | ) |
set a helper to filter out some collisions for this sprite
Sets up a handler to do special case collision logic between two sprites. For example, you might want bullet sprites to collide with enemy sprites but not with one another. If a collide helper is installed, then on initial contact between two sprites the collide helper for the moving sprite will be called, and your helper can decide if the collision should happen or not.
helper | an ISpriteCollideHelper instance that will filter some collisions. |
setCollisionRadius | ( | number | pixelRadius | ) |
set the radius of the collision boundary circle of the sprite
The boundary circle is centered at the sprite's location.
setDrawHelper | ( | ISpriteDrawHelper | helper | ) |
set a pre-draw helper for custom sprite drawing
Sets a helper to do extra drawing stuff for this Sprite. This helper will be called before the Sprite draws normally, and can block normal sprite drawing by returning false from the helper function.
If you want to do overlay effects, use the post-draw helper for that (see setPostDrawHelper)
helper | the pre-draw helper that you want use to add background effects or replace normal rendering of the sprite |
Sprite setElasticity | ( | number | elasticity | ) |
Sprite setEntityScale | ( | number | xScale, |
number | yScale | ||
) |
Sprite setFrame | ( | int | frame | ) |
Sprite setMouseDetectMode | ( | int | collisionType = collide_BoundingBox | ) |
Sprite setOpacity | ( | number | opacity | ) |
setPostDrawHelper | ( | ISpriteDrawHelper | helper | ) |
Sprite setWantsAnimEndEvents | ( | boolean | wantsThem = true | ) |
Sprite setWantsAnimLoopEvents | ( | boolean | wantsThem = true | ) |
Sprite setWantsClickEvents | ( | boolean | wantsThem = true | ) |
Sprite setWantsCollideWallEvents | ( | boolean | wantsThem = true | ) |
Sprite setWantsMouseOverEvents | ( | boolean | wantsThem = true | ) |
Sprite setWantsOffscreenEvents | ( | boolean | wantsThem = true | ) |
slideJoint | ( | Offset | anchor, |
Sprite | otherSprite, | ||
Offset | otherAnchor, | ||
number | minDist, | ||
number | maxDist, | ||
number | breakingForce = 0 |
||
) |
join sprites together via a slider between anchor points that has a min/max distance (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of force is applied to the joint.
springJoint | ( | Offset | anchor, |
Sprite | otherSprite, | ||
Offset | otherAnchor, | ||
number | restLength, | ||
number | stiffness, | ||
number | damping, | ||
number | breakingForce = 0 |
||
) |
join sprites together via a spring between anchor points (Chipmunk Physics Only)
If a breaking force is given, then the joint will break, generating a SpriteBreakEvent, if greater than that amount of force is applied to the joint.
startAnimation | ( | int | animationId | ) |
startAnimation | ( | string | animationName | ) |
startFrameAnimation | ( | number | fps, |
int | startingFrame = start_FromFirstFrame , |
||
int | numFrames = all_Frames , |
||
int | animateFlags = animate_Looping |
||
) |
stopFrameAnimation | ( | ) |