Hi I am making a quick program of a guy in my game and I need the right key to make him move right, same with left. But For some reason it wont work but my code has no errors. Can an animated sprite not be assigned functions like this? Do I need to make an alias or something? Here is my code
import QtQuick 2.7
import QtQuick.Window 2.2
Item {
width:Screen.width
height:Screen.height-10
Keys.onPressed: {
if (event.key===Qt.Key_up){
event.accepted = true;
sprite2.y=(sprite2.y) +25
}
}
Flickable{
width:Screen.width
height:Screen.height
contentHeight: Screen.height *4
contentWidth: Screen.width
interactive: true
boundsBehavior: Flickable.StopAtBounds
Image{
id: box
anchors.fill: parent
source: "artwork/rect.png"
sourceSize.width: Screen.width
sourceSize.height: Screen.height*4
}
AnimatedSprite {
id: sprite2
width: 100
height: 200
anchors.centerIn: parent
source: "artwork/WalkingManSpriteSheet.png"
frameCount: 8
frameRate: 6
frameWidth: 40
frameHeight:60
loops: 100
}
Image{
id:twitter
source: "artwork/twitter.png"
x:500
y:horizontalCenter
}
AnimatedSprite {
id: sprite
width: 300
height: 425
anchors.centerIn: hoizontalCenter
source: "artwork/cannon.png"
frameCount: 12
frameRate: 8
frameWidth: 128
frameHeight:155
loops: 100
}
}
}