Sprite vs Texture2d
Introduction
Sprite sprite = SpriteManager.AddSprite("redball.bmp");Image, Texture2D, and Sprite
Dissecting AddSprite
Sprite sprite = SpriteManager.AddSprite("redball.bmp");// Identify the image file that will be used to create the Texture
string textureFileName = "redball.bmp";
// Identify the content manager that will be used to create the Texture
string contentManagerName = FlatRedBallServices.GlobalContentManager;
// Use these two to create the texture
Texture2D texture2D = FlatRedBallServices.Load<Texture2D>(
textureFileName,
contentManagerName);
// Create the Sprite
Sprite sprite = new Sprite();
// Assign the Texture2D
sprite.Texture = texture2D;
// Finally, add the Sprite to the SpriteManager for manageemnt
SpriteManager.AddSprite(sprite);Texture Caching
Last updated
Was this helpful?