Bouncing Hello World

Let’s make our previous post a little bit more interesting. We add an animation to the text, which allows the text to bounce vertically on the screen. The changes are small, but the effect is pretty cool.

import Qt 4.6

Rectangle {
  width: 200
  height: 200
  Text {
    x: 66
    y: SequentialAnimation { // new animation
      running: true
      repeat: true
      NumberAnimation { to: 150; easing: "easeOutBounce"; duration: 2000 }
      PauseAnimation { duration: 1000 }
      NumberAnimation { to: 50; easing: "easeOutQuad"; duration: 1000 }
    text: "Hello World"

Instead of having the text y position fixed, we bind it to an animation. The animation consist of a sequential running animation and a set of animations, which control the y variable. To get the bounce effect, we use a bounce easing curve.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s