Animation
This example program
shows how to animate sprites by loading in a series of images. The images are
displayed in sequence for a short amount of time. A variable is used to time each
frame. When you run the example you should see a screen similar to the one
below. The explosion animation repeats indefinitely but changes its position
after each loop. The spaceship sprite in the bottom left corner of the screen
simply rotates in place.
This project also demonstrates blending mode 3,
additive transparency. The explosion and spaceship images are jpeg, which means
they don’t have alpha channels. With blending mode 3, the dark areas of an
image will appear transparent, and the brighter portions of the image will
brighten the background.
A detailed explanation of the code is provided in the
comments. Please read through all the comments and code found in Main.cpp. And as always, feel free to experiment with the
code or replace the graphics with your own designs. Download the Visual Studio
project by clicking on the link below:
Animation.zip 353KB