
1395.7. Simple Animation
}
setRect(); // Set spriteData.rect
}
}
}
Listing 5.36. e Image::update function.
e setRect function uses the current frame number to calculate the rectangular
portion of the texture image to display. e spriteData.width, spriteData.height,
and cols data describe the texture image of our spaceship (Listing 5.37).
//========================================================================
// Set spriteData.rect to draw currentFrame
//========================================================================
inline void Image::setRect()
{
// Configure spriteData.rect to draw currentFrame
spriteData.rect.left = (currentFrame % ...