Chaining multiple animations

What if we wanted to perform an animation at the end of another animation? We could connect the finished() signal of the first animation to the start() slot of the second one. However, a much more convenient solution is to use QSequentialAnimationGroup. For example, if we want coins to scale and then to fade, the following code will do the trick:

QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this);
group->addAnimation(scaleAnimation);
group->addAnimation(fadeAnimation);
group->start();

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.