Bear cannot move in sprite, Help !!



  • 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

    @

    import QtQuick 2.0
    Rectangle {

    color:"blue"
    width: 800
    height:800
    id: root

    SpriteSequence{
    sprites: Sprite{
    name:"bear"
    source: "file:///home/common/Desktop/bear.png"
    frameCount:13
    frameDuration: 120
    }
    width:250
    height:250
    x:20
    anchors.bottom:parent.bottom
    anchors.bottomMargin:20
    X=4
    }
    MouseArea {
    id:mouse
    anchors.fill:parent
    }
    }
    @
    -----Second attempt 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);
                     }
                          }
              }
                 }
    

    }

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

    @


Log in to reply
 

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