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 ...

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.