Sprite script interface
The ISpriteInstance
interface derives from IWorldInstance to add APIs specific to the Sprite plugin.
Sprite events
See instance event for standard instance event object properties.
- "framechange"
- Fired when the currently displayed animation frame changes during playback of an animation. The event object has the additional properties:
animationName
: a string of the name of the currently playing animation
animationFrame
: a zero-based index with the animation frame number of the new frame in its animation
- "animationend"
- Fired when playback of the current animation reaches the end. The event object has the additional properties:
animationName
: a string of the name of the animation that finished
Sprite APIs
- animation
- A reference to a IAnimation script interface representing the current animation, which can be used to access additional details such as the frames in the animation.
- 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.
- getAnimation(name)
- Get an IAnimation for an animation in the Sprite object by a case-insensitive string of its name. Returns
null
if no animation is found.
- 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
Construct.net
2019-06-03
2022-02-28
You are here:
Search this manual:
This manual entry was last updated on 28 Feb, 2022 at 17:40