C
AnimatedSpriteDirectory QML Type
Draws a sprite animation stored in a directory. More...
Import Statement: | import QtQuickUltralite.Extras 2.10 |
Since: | Qt Quick Ultralite 2.4 |
Inherits: |
Properties
- currentFrame : int
- frameDuration : int
- loops : int
- paused : bool
- running : bool
- sourcePath : string
Signals
- finished()
Methods
Detailed Description
The AnimatedSpriteDirectory type behaves as AnimatedSprite, except that it gets the images for the sprite animation. It needs the sourcePath value to be the directory path that has a series of images. These images are the frames of a sprite animation, and the AnimatedSpriteDirectory plays each image as AnimatedSprite does.
The sequence of the animation frames follows the list order of the images in a ImageFiles node. Tag these image files with ImageFiles.MCU.resourceAnimatedSprite, to make sure the Qt Quick Ultralite Tools identify them as candidates for sprite animation frames. Tagging these images also enables identifying their directory name and rendering each image correctly.
QML | Image declaration in QML project |
---|---|
import QtQuickUltralite.Extras AnimatedSpriteDirectory { sourcePath: "loading" } | ImageFiles { files: [ "loading/01.png", "loading/02.png", "loading/03.png", "loading/04.png" ] MCU.resourceAnimatedSprite: true } |
Unlike AnimatedSprite, AnimatedSpriteDirectory does not have the frameCount, frameWidth, and frameHeight properties. It gets these values from the images in the given directory. The no. of images in the directory as the frameCount, width and height of those images as frameWidth and frameHeight respectively.
Note: All the images should have the same width and height, otherwise the resource compiler (qulrcc tool) cannot generate raw image data.
See also Managing resources.
Property Documentation
currentFrame : int |
Set this property to advance the current frame manually, when the animation is not active. You could also call the advance() method.
frameDuration : int |
Duration of each frame of the animation in milliseconds. Only positive values are valid.
Changing this property while the animation is active, will restart the animation.
loops : int |
Indicates the no. of times the animation should replay. Only positive values are valid.
Set it to AnimatedSpriteDirectory.Infinite
to play the animation infinitely.
Default is AnimatedSpriteDirectory.Infinite
.
paused : bool |
Indicates whether the animation is paused or not.
When the animation is paused, you can advance its current frame manually.
Default is false
running : bool |
Indicates whether the animation is playing or not.
Default is true
.
sourcePath : string |
Path to the directory with images for the sprite animation. Tag the images in the path by setting the ImageFiles.MCU.resourceAnimatedSprite property to true
in the ImageFiles node.
Note: The given sourcePath
is invalid if you don't tag the images.
Signal Documentation
finished() |
This signal indicates that the sprite animation completed.
It is not emitted if you set either the running
property to false
or loops
property to AnimatedSpriteDirectory.Infinite
.
Note: The corresponding handler is onFinished
.
Method Documentation
advance() |
Advances the sprite animation by one frame.
pause() |
Pauses the sprite animation. This does nothing if paused is true
.
restart() |
Restarts the sprite animation.
resume() |
Resumes the sprite animation if paused is true
. Otherwise, this does nothing.
start() |
Starts the sprite animation. If the animation is already running, calling this method has no effect.
stop() |
Stops the sprite animation. If the animation is not running, calling this method has no effect.
Available under certain Qt licenses.
Find out more.