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. Bear cannot move in sprite, Help !!
QtWS25 Last Chance

Bear cannot move in sprite, Help !!

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 436 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 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

    @

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

    }

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

    @

    1 Reply Last reply
    0

    • Login

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