Chapter 4’s Slideshow Was No Problem

September 12, 2021 Posted by zachary

Just finished up Chapter 4 of Beginning Game Programming by Michael Morrison. This chapter taught new game developers about bitmaps and how to use them in their games. Since HaxeFlixel handles all those details, I didn’t need to write up a class to read and display them. So I jumped right to the example at the end, A Slideshow.

For this, I used it as an introduction to HaxeFlixel’s sprite animation functionality. The FlxSprite class has some built in animation functionality that you can use to to create a slideshow effect.

// This sprite fills the entire screen, so its size is the size of the game window. 
// The "true" parameter indicates that this sprite is animated.
loadGraphic(AssetPaths.ManlyBoy__png, true, 320, 180);

// Create an animation called "slide" which just goes through each frame at 1 frame per second, then loops.
animation.add("slide", [0, 1, 2, 3, 4], 1, true);

// Play the created animation"slide");

The only downside to doing a slideshow this way is that a FlxSprite cannot be animated at fewer frames than 1 per second. Which for a game, makes sense, but for a slideshow, it doesn’t. I could have easily done the same thing using 5 or 6 separate sprites inside of a FlxGroup and just reordered them every few seconds, but I wanted to play with animation.

In the end, we have a slideshow of screenshots from the Divine Knight Gaming game Manly Boy.

This project ends the first section of Beginning Game Programming. The next four projects will be adding player input using keyboard, mouse, and controllers. So this will be a lot of fun.

You can checkout the Slideshow at And you can see the source code over at Github.

NOTE: When I was finishing up the merges for the source code on this project, I noticed that I was misnaming my branches. I have been using the abbreviation bcg instead of bgp. Not sure why. So that will be fixed going forward.

Leave a Reply

Your email address will not be published. Required fields are marked *