How to use QML sprite.(solved)



  • 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);
                     }
                          }
              }
                 }
    

    }

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

    @



  • 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
    }
    }
    @



  • "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?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.