Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How QML cycle sprites?

How QML cycle sprites?

Scheduled Pinned Locked Moved Game Development
11 Posts 4 Posters 8.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cochise
    wrote on 17 Nov 2010, 20:38 last edited by
    #2

    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.

    http://cochise.tumblr.com

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jkosonen
      wrote on 17 Nov 2010, 20:49 last edited by
      #3

      But you need to add some kind of timer? you can't just animate the image with plain QML syntax?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cochise
        wrote on 17 Nov 2010, 21:03 last edited by
        #4

        well a "quick" search show-me "this":http://doc.qt.nokia.com/4.7/qml-animatedimage.html

        http://cochise.tumblr.com

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on 17 Nov 2010, 22:52 last edited by
          #5

          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

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cochise
            wrote on 18 Nov 2010, 00:53 last edited by
            #6

            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.

            http://cochise.tumblr.com

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jkosonen
              wrote on 18 Nov 2010, 05:43 last edited by
              #7

              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...

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kxyu
                wrote on 21 Nov 2010, 17:24 last edited by
                #8

                It's surely possible, and there are several ways to implement this
                keywords are Image, Timer and crop

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jkosonen
                  wrote on 21 Nov 2010, 20:41 last edited by
                  #9

                  Cool, thanks, found info about the timer with google, but how does that image cropping work?

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    Kxyu
                    wrote on 22 Nov 2010, 08:06 last edited by
                    #10

                    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:0

                        anchors.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
                                 }
                    }
                    

                    }
                    @

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jkosonen
                      wrote on 22 Nov 2010, 11:19 last edited by
                      #11

                      Hey thanks!

                      1 Reply Last reply
                      0

                      11/11

                      22 Nov 2010, 11:19

                      • Login

                      • Login or register to search.
                      11 out of 11
                      • First post
                        11/11
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved