How QML cycle sprites?
-
Hi,
so how can it be achieved in QML that you can cyckle images in a one sprite?
Thanks! -
God question.
If you use QML with Qt app you can use qtimer for change the source property.
if you using javascript you can use timeout unction. -
But you need to add some kind of timer? you can't just animate the image with plain QML syntax?
-
well a "quick" search show-me "this":http://doc.qt.nokia.com/4.7/qml-animatedimage.html
-
It will help you only if you have ready gif file. If you have animation in one jpg file or if you multiple files (one for each frame) it will not help you
-
i not try with tiff files. Maybe work.
Create a image with many layers as positions is easy. The problem is the gif poor quality.
-
Yes, i was interested when you have the animation in one jpg (or other format) file... but maybe that's not possible currently with QML then...
-
It's surely possible, and there are several ways to implement this
keywords are Image, Timer and crop -
Cool, thanks, found info about the timer with google, but how does that image cropping work?
-
ups, sorry, just a mistake. i mean clip. works like this:
@import Qt 4.7
Rectangle {
id:screen
width:1024
height:600
Item{
id:spriteAnimation
property int framesCount:8
property int currentFrame:0anchors.centerIn:parent clip:true height:spriteAnimationImage.height width:spriteAnimationImage.width/framesCount Image{ id:spriteAnimationImage source:"http://chikuyonok.ru/u/2009/05/elephant.jpg" y:0 x:-spriteAnimation.width*spriteAnimation.currentFrame } } Timer{ id:spriteAnimationTimer interval:50 running:true repeat:true onTriggered:{ spriteAnimation.currentFrame++ spriteAnimation.currentFrame%=spriteAnimation.framesCount } }
}
@ -
Hey thanks!