Time for action – adding jumping with sprite transitions
Let's replace the AnimatedSprite class with the SpriteSequence class in the Bejamin the Elephant animation, adding a sprite to be played during the jumping phase.
Open the Player.qml file and replace the AnimatedSprite object with the following code:
SpriteSequence {
id: sprite
width: 80
height: 52
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
currentSprite: "still"
running: true
Sprite {
name: "still"
source: "images/walking.png"
frameCount: 1
frameWidth: 80
frameHeight: 52
frameDuration: 100
to: {"still": 1, "walking": 0, "jumping": 0}
}
Sprite {
name: "walking"
source: "images/walking.png"
frameCount: 7
frameWidth: 80
frameHeight: 52
frameRate: 10
to: {"walking": 1, "still": 0, "jumping": 0}
}
Sprite...