SkiaSpriteCanvas

Introduction The SkiaSpriteCanvas type provides a Skia canvas which can be used to render any Skia graphics. All rendering performed on the canvas is efficiently converted to a Texture2D. SkiaSpriteCanvas inherits from the standard FlatRedBall Sprite, so it provides all of the common Sprite functionality including: Attachment to entities Sorting according to the SpriteManager settings Rotation,[…]

03 – Loading Textures and Using Sprites

Introduction Textures (which use the type Microsoft.Xna.Framework.Graphics.Texture2D) are used to draw graphics on the screen. A Texture is a resource which is usually loaded from .png and is drawn to the screen using the Sprite type. This code-only tutorial shows how to load a PNG to disk and how to draw it on screen using[…]

RenderTargetSprite

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

Sprites

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

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