Xbox LIVE Indie Games

code sample details

Sprite Sheet

Code Sample

Description: 

This sample shows how to implement sprite sheets, combining many separate sprite images into a single larger texture that will be more efficient for graphics hardware.

Sample Overview

Manually combining sprite images into larger sheets works well if you have just a few sprites, but it quickly becomes a burden as your game grows larger. When you have hundreds of sprites, it can be laborious to manually pack them all into a single sprite sheet texture, and then to remember where you put each image so that you know what source rectangle to pass to SpriteBatch.Draw in your game code.

This sample automates the process of creating sprite sheets by using a custom content processor. You provide an XML file listing any number of individual bitmap files, one per sprite. The processor reads all these bitmaps, packs them into a single larger texture, and saves this new texture along with information recording which source rectangle should be used for each sprite. You can then look up your sprites by name, rather than having to remember the specific coordinates for each image.



All content and source code downloaded from this page are bound to the Microsoft Permissive License (Ms-PL).

downloads

Framework

GS 4.0

Framework

GS 3.1

find education content
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG