SpineSkeleton is the base type for all bone-based animations created with the Spine framework. More...
Import Statement: | import Felgo 3.0 |
Since: | Felgo 2.8.1 |
Inherits: |
Spine animations are integrated in Felgo by converting Spine entities to QML objects. See the guide How to Add Skeleton Animations by Spine to Your Felgo Game for more information. Every QML spine entity that is created that is based on the SpineSkeleton type.
These objects provide aliases for all animations defined in Spine. For example, if an animation is called "walk" in Spine, it can be accessed by the property "walkAnimation". All animations are implemented as standard Qt Animation objects, but should be started by calling animate().
The following example shows how to start an animation, that is called "walk" in Spine, on a Spine entity called MySpineObject:
MySpineObject { id: spineObj }
spineObj.animate(spineObj.walkAnimation);
To check whether an animation is currently running, the currentAnimation and Animation::running property can be used:
if(spineObj.currentAnimation && spineObj.currentAnimation.running) { //animation is currently running }
To control a running animation, use the functions
of Animation:
spineObj.currentAnimation.pause();
To control how often the animation loops, set the Animation::loops property. To infinitely loop, set it to Animation::Infinite.
Note: set this property before starting the animation with animate()!
spineObj.walkAnimation.loops = Animation.Infinite;
It is also possible to access the current dimensions (bounding box) via the boundingBox and boundingBoxItem properties.
The bounding boxes are newly calculated whenever the different bones and images of a spine object change their position, so having them enabled on a lot of objects can have a negative impact on performance. For this reason,
SpineSkeleton provides the boundingBoxEnabled property, which is false
by default. If you need to know the animation's dimensions, set it to
true
.
[read-only] boundingBox : rect |
This property holds a bounding box around the Spine object. As the object animates, this bounding box's position and size might change.
This property is only set and updated, if boundingBoxEnabled is set to true.
boundingBoxEnabled : bool |
Set this property to true if the boundingBox and boundingBoxItem properties should be updated.
Default value is false, to improve performance.
[read-only] boundingBoxItem : Item |
This is a QML item which fills the boundingBox.
This property is only set and updated, if boundingBoxEnabled is set to true.
This can be used to anchors items to fill the bounding box:
MySpineObj { id: mySpineObj Rectangle { color: "#40ff0000" //semi transparent anchors.fill: mySpineObj.boundingBoxItem } }
[read-only] currentAnimation : Animation |
imageFolder : string |
The folder where the animation images are loaded from, relative to the location of the Spine QML item.
void animate(Animation animation) |
Start an animation. The animations are properties of the converted QML spine objects.
Example usage of starting an animation called "walk" in Spine, on an animation object called MySpineObject:
MySpineObject { id: spineObj }
spineObj.animate(spineObj.walkAnimation);
Reset the animation to its initial state. All bones will be reset to their initial position, rotation and scale.