SpriteBatch

Introduction SpriteBatch allows games to render 2D graphics to screen. Unlike FlatRedBall’s Sprite class, SpriteBatch performs immediate rendering – drawing with SpriteBatch results in graphics appearing for only one frame. To keep SpriteBatch graphics on screen for an extended amount of time, Draw must be called every frame. By contrast, FlatRedBall Sprites can be created[…]

IsSpriteInView

Introduction The IsSpriteInView method reports whether the argument Sprite is in view given the Camera’s position, the Sprite’s position, and the CameraCullMode. If the CameraCullMode is set to CameraCullMode.None then this value will always return true. If the CameraCullMode is set to CameraCullMode.UnrotatedDownZ then this will calculate whether the Sprite is in view or not.[…]

RemoveSpriteOneWay

Introduction The RemoveSpriteOneWay method removes the argument Sprite from the SpriteManager (for both rendering and automatic updates) but does not modify any relationships between the Sprite and objects outside of the game engine. Specifically, RemoveSpriteOneWay will remove a Sprite from: Rendering Ordered rendering Z-Buffered rendering Layered rendering Automatic engine updates RemoveSpriteOneWay will not remove a[…]

03 – Measuring Sprite Automatic Updates

Introduction This section will walk you through identifying how many Sprites you have in your game, and how you can reduce this number to improve performance. If you haven’t yet, you should first read the article about measuring all PositionedObjects. This article can be found here. If Sprites are the majority If you’ve used WriteAutomaticallyUpdatedObjectInformation[…]

OrderedSprites

Introduction The OrderedSprites list contains all of the Sprites that will be rendered by the SpriteManager. It does not include any Sprites which are on Layers, nor any Sprites which are z-buffered. This list can be used at runtime to verify whether Sprites that you expect to be created actually are created, or to investigate[…]

Sprite

Introduction Sprites are used to render a texture to the screen. Sprites are one of the most common types of FlatRedBall objects. Examples of Sprites include: Character graphics (static or animated) Backgrounds Particles Tile graphics Bullets Creating an Entity With a Sprite If you know that your entity needs a Sprite, you can check the[…]

FlatRedBallXna:Tutorials:Clipping Sprites

Introduction Clipping is the process of removing part of a Sprite from being rendered by defining a rectangular area which will contain the Sprite. This tutorial will show you how to write code to clip Sprites within a rectangle. This form of clipping has some requirements: The Sprite being clipped must not be rotated The[…]

ConvertToZBufferedSprite

Introduction The ConvertToZBufferedSprite method can be used on Sprites which have already been added to the SpriteManager as ordered (not z-buffered). This method assumes: That the argument Sprite has already been added to the SpriteManager That the Sprite is not on a Layer Code Example The following code adds a Sprite regularly, then converts it[…]

FlatRedBall.Scene.Sprites

Introduction The Sprites member in a Scene provides access to the contained Sprites. Accessing the Sprites You can simply loop through the Sprites to make changes. For example, the following code sets all contained Sprites’ Alpha to 0:

Getting the dimensions of your Scene Scenes do not have an inherent width or height because[…]