Game Programming using Qt 5 Beginner's Guide - Second Edition
by Pavel Strakhov, Witold Wysota, Lorenz Haas
What just happened?
A number of images were prepared following a common naming pattern containing a number. All the images have the same size. This allows us to replace one image with another just by changing the value of the source property to point to a different image. To make it easier, we introduced a property called the currentFrame element that contains the index of the image to be displayed. We used the currentFrame element in a string, forming an expression bound to the source element of the image. To make substituting frames easy, a NumberAnimation element was declared to modify the values of the currentFrame element in a loop from 1 to the number of animation frames available (represented by the frameCount property) so that each ...
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