Sprite script interface

The ISpriteInstance interface derives from IWorldInstance to add APIs specific to the Sprite plugin.

Sprite APIs

setAnimation(name, from = "beginning")
Set the current animation by a string of its name (case-insensitive). from can be set to either "current-frame" to switch to the same frame index in the new animation, or "beginning" to rewind to the first frame.
animationName
A read-only string of the current animation name. Use the setAnimation() method to change the animation.
startAnimation(from = "current-frame")
Start playback of the current animation. from can be set to either "current-frame" to play from the existing frame, or "beginning" to play from the first frame.
stopAnimation()
Stop playback of the current animation.
animationFrame
The zero-based index of the current animation frame.
animationSpeed
The current animation playback speed, in animation frames per second.
animationRepeatToFrame
The zero-based index of the animation frame to rewind to when repeating an animation.
imageWidth
imageHeight
Read-only numbers indicating the size of the current animation frame's source image, in pixels.
getImagePointCount()
Return the number of image points on the current animation frame.
getImagePointX(nameOrIndex)
getImagePointY(nameOrIndex)
getImagePoint(nameOrIndex)
Return the location of an image point on the current animation frame in layout co-ordinates. Image points are identified either by a case-insensitive string of their name, or their index. Note image point 0 is the origin, so index 1 is the first image point. If the image point is not found, this returns the origin instead. The getImagePoint variant returns [x, y].
getPolyPointCount()
Return the number of collision polygon points on the current animation frame.
getPolyPointX(index)
getPolyPointY(index)
getPolyPoint(index)
Return the location of a collision polygon point on the current animation frame in layout co-ordinates, by its zero-based index. The getPolyPoint variant returns [x, y].
Construct 3 Manual 2020-06-16

On this page