02 – Creating Sprite and Collision

Introduction Even though Super Mario World is considered an old game, Mario has a lot of behaviors. In fact, Super Mario World is complex enough that a tutorial which implemented all functionality would be considerably longer than this one. Therefore, we’ll skip over a number of behaviors and instead focus on the following: Idle Walk[…]


Introduction The RenderTargetSprite class provides a simple way to perform rendering using a RenderTarget2D. Although FlatRedBall provides support for using MonoGame render targets, the RenderTargetSprite simplifies the creation and management of render targets. RenderTargetSprite instances provide a FlatRedBall Layer for adding visual objects to the sprite. RenderTargetSprite Concepts To understand how a RenderTargetSprite works, we can[…]


Introduction The Sprites collection provides access to all ordered Sprites stored within this layer. This is a read-only collection so it cannot be directly modified through the layer. Note that this list only contains ordered sprites. Z-buffered sprites are stored in the Layer’s ZBufferedSprites property. Code Example The Sprites property can be used to check if[…]


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[…]


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.[…]


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[…]


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[…]


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[…]