What just happened?

You already know how to set up a single property animation, so we omitted the code for it. After setting up both animations, we add them to the group animation by calling addAnimation() on the group, while passing a pointer to the animation we would like to add. Then, when we start the group; QParallelAnimationGroup ensures that all assigned animations start at the same time.

When both animations have finished, group will emit the finished() signal. We connected that signal to the deleteLater() slot of our class so that the coin object gets deleted when it's no longer visible. This handy slot is declared in the QObject class and is useful in many cases.

In some cases, you may want to stop an animation. You can do that ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.