Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to use QML sprite.(solved)
Forum Update on Monday, May 27th 2025

How to use QML sprite.(solved)

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 1 Posters 1.2k 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.
  • H Offline
    H Offline
    houmingc
    wrote on 19 Dec 2014, 01:10 last edited by
    #1

    I would like to learn how to use sprite.
    I found the link below: but i can't find starfish_1.png
    https://qt.gitorious.org/qt/qtdeclarative/source/75a0d33d250a97d5ee0314f5b7aad876d9ee2fa8:examples/particles/imageparticle/sprites.qml

    bear_tiles.png file can be downloaded at the link below
    http://m.blog.csdn.net/blog/u011348999/35786691

    Below is my code

    -----no:error, but i could not see anything--------------
    @

    import QtQuick 2.2
    import QtQuick.Window 2.1

    Window {
    visible: true
    width: 3600
    height: 3600

    Rectangle{
        anchors.fill: parent
        color:"white"
    }
    AnimatedSprite{
    
               id: sprite
               width:170
               height:170
               anchors.centerIn: parent
               source:"file:/home/common/Desktop/beach.png"
               frameCount:13
               frameDuration: 120
               loops: 3
    
    
     MouseArea {
    
                anchors.fill:parent
                acceptedButtons:Qt.LeftButton | Qt.RightButton
                onClicked: {
                    if(!sprite.running)
                                           sprite.start();
                    if(!sprite.paused)
                                            sprite.paused();
                    if(mouse.button==Qt.LeftButton){
                        sprite.advance(1);
                    }
                    else {
                        sprite.advance(-1);
                     }
                          }
              }
                 }
    

    }

    ========================

    @

    1 Reply Last reply
    0
    • H Offline
      H Offline
      houmingc
      wrote on 21 Dec 2014, 07:14 last edited by
      #2

      I got it using animatedSprite, anyone can mk it work using animatedsequence.
      @
      import QtQuick 2.2
      import QtQuick.Window 2.1

      Window
      {
      visible: true
      width: 640
      height: 480
      flags: Qt.FramelessWindowHint
      | Qt.Window
      color:"#00000000"
      title:"Presenter Remote"

      Rectangle{
      color:"steelblue"
      height:parent.height
      width:parent.width
      radius: 10
      }

      Image {
      anchors.right: parent.right
      anchors.top: parent.top
      anchors.topMargin: -20
      scale: 0.5

         source: "file:///home/common/apps/Qtdir2/untitled40/close.jpeg"
         MouseArea {
             width:parent.width
             height:parent.height
             onClicked: Qt.quit()
         }
      

      }

      AnimatedSprite{

      source: "file:///home/common/apps/Qtdir2/untitled40/Animation_Cloud.png"
      anchors.centerIn: parent
      frameHeight:313
      frameWidth:232
      running: true
      frameCount:60
      frameDuration: 20
      width:232
      height:313
      }
      }
      @

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on 22 Dec 2014, 15:34 last edited by
        #3

        "sprites picture":http://pxlcobit.deviantart.com/art/MLSS-Hammer-and-Boomerang-Mario-sprites-sheet-309187434

        I would like to use irregular sprite like attach. Where to find help?

        1 Reply Last reply
        0

        3/3

        22 Dec 2014, 15:34

        • Login

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