How QML cycle sprites?
-
wrote on 17 Nov 2010, 20:38 last edited by
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. -
wrote on 17 Nov 2010, 20:49 last edited by
But you need to add some kind of timer? you can't just animate the image with plain QML syntax?
-
wrote on 17 Nov 2010, 21:03 last edited by
well a "quick" search show-me "this":http://doc.qt.nokia.com/4.7/qml-animatedimage.html
-
wrote on 17 Nov 2010, 22:52 last edited by
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
-
wrote on 18 Nov 2010, 00:53 last edited by
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.
-
wrote on 18 Nov 2010, 05:43 last edited by
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...
-
wrote on 21 Nov 2010, 17:24 last edited by
It's surely possible, and there are several ways to implement this
keywords are Image, Timer and crop -
wrote on 21 Nov 2010, 20:41 last edited by
Cool, thanks, found info about the timer with google, but how does that image cropping work?
-
wrote on 22 Nov 2010, 08:06 last edited by
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 } }
}
@ -
wrote on 22 Nov 2010, 11:19 last edited by
Hey thanks!
11/11