-
Notifications
You must be signed in to change notification settings - Fork 111
SpriteBase Guide
"SpriteBase" is a known engine type that handles the rendering properites of the scene objects "Sprite" and "Scroller". SpriteBase is derived from a base type called "SceneObject". That means it includes all the fields from that type as well as adding its own fields specific to itself.
Although it handles the assignment of image properties, a SpriteBase object cannot render itself within a scene. As such, it is not included in the list of scene objects available for use within a game.
The SpriteBase type exposes the following fields in addition to those it inherits. Shown are the equivalent methods available that perform the same action in setting and getting the respective field:
- Image
- setImage(imageAssetId)
- getImage()
- Frame
- setImageFrame(int)
- getImageFrame()
- Animation
- playAnimation(animationAssetId)
- getAnimation()
The following is a complete description of each of these fields.
Specifies the ImageAsset to be used for the object derived from SpriteBase. This must be given as a valid ImageAsset ID.
%object.Image = "ToyAssets:Tiles";
Sets the object derived from SpriteBase to use the specified image frame.
%object.Frame = 1;
Specifies the AnimationAsset to be used for the object derived from SpriteBase. This must be given as a valid AnimationAsset ID.
%object.Animation = "ToyAssets:TileAnimation";
The SpriteBase type has the following callbacks in addition to those it inherits.
This is called when the animation reaches the last frame it is supposed to play. Note that a looping animation would not trigger this callback as the animation continues from the last frame back to the first frame without stopping.
The following methods are available to further configure and control SpriteBase or its derived object classes.
Gets whether the sprite is in static or dynamic (animated) mode.
If true, this pauses the current animation. When set to false, the animation will continue its playback.
Stops the current animation. This also results in a reset of the animation cycle, so the animation would start at the beginning if played again.
This manually sets the frame of the animation to play.
Gets the current animation frame.
Gets the current animation time.
Checks the animation status to find out whether the animation has finished playing or not.
This method will change the rate of animation. It scales the animation speed, with a speed of 1 being the default.
This method will return the value of the animation time scale.