The Learning Kyra series to date:
- Learning Kyra
- Learning More Kyra
- Learning Kyra: Attack of the Clones
- Learning Kyra: Tiles and Z-Ordering
- Learning Kyra: Hit Detection
For instance, GlDynArray has been removed from the library for the next update. I can substitute std::vector<> though, which for all intents and purposes means very little has changed except for a redirection/abstraction. For now, I need to use it when doing hit detection, but I shouldn’t rely on it for my own code.
I was thinking about the need for more complex animations and Actions for an individual sprite. For example, a sprite may have a standing animation. When you press the space bar, an attack animation should run, but I might not want it to loop over and over. Was I going to have to keep track of how many frames of animation there were for a given Action in order to make sure it doesn’t loop?
Nope! Turns out that Kyra’s KrSprite class has functions for determining the number of frames for an animation and for getting the current frame. Now I can do something like the following:
if ( theSprite->Frame() >= numFrames )
// then the ATTACKING animation is over and should change state
I also found that a sprite can clone itself. In my June GID, I had these fuzzy creatures multiplying, but I loaded in a resource from a file and created a sprite from the resource. I originally thought that I could optimize it by storing the resource to be used later, but I could further optimize by just using the Clone() function to create a new sprite. I could also use GetResource to get a pointer to the resource used by an existing sprite if I really needed it.
I want to work on some code to test what I’ve learned to see how well it works. I can get something substantial completed this week.