Learning Windows 8 Game Development
上QQ阅读APP看书,第一时间看更新

What a sprite is

Sprites and textures are pretty similar, but their differences appear when you look at what they do when the game is running. A texture is quite simply a 2D image that we can generate or load from the disk. In many cases, sprites are the same as textures, and you won't need to worry about them. Technically though, a sprite is a runtime representation of the image within the context of the game scene. This is because we can use parts of the texture (or multiple textures) as a sprite, giving the illusion of a complete image coming from a single texture. The difference really appears when you have sprite sheet-based animations (animations with each frame arrayed on the same texture).

Note

Sprites were originally images that sat on top of the frame buffer, seemingly integrated into the bitmap even though they were just layered on top. These days sprites just refer to individual images displayed to the player.

When you look at an animation, you will see a series of frames displayed in rapid sequence, giving the illusion of movement. Often these frames are packed together on a single texture, also known as a sprite sheet. The texture is always the full image with all frames; however, when displayed within the context of the game, only single frames are drawn, and this display of frames as a single object is called the sprite.

Example Sprite Sheet

Credits: Reemax & artisticdude

Sprites can range from representing the player or enemies with animations, to static objects that fill the entire background. Sprites may be rotated, scaled, moved, or even layered with other sprites, allowing for on the fly positioning and customization.