Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
A third way of animation
Besides QTimer and QPropertyAnimation, there is a third way to animate the scene. The scene provides a slot called advance(). If you call that slot, the scene will forward that call to all items it holds by calling advance() on each one. The scene does that twice. First, all item advance() functions are called with 0 as an argument. This means that the items are about to advance. Then, in the second round, all items are called passing 1 to the item's advance() function. In that phase, each item should advance, whatever that means—maybe moving, maybe a color change, and so on. The scene's slot advance is typically called by a QTimeLine element; with this, you can define how many times during a specific period of time ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access