Table of Contents

Class SpriteRenderer

Namespace
MonoEight.Core.Sprite
Assembly
MonoEight.Template.dll

A Component for rendering a Microsoft.Xna.Framework.Graphics.Texture2D to the screen.

public class SpriteRenderer : Component, IDisposable
Inheritance
SpriteRenderer
Implements
Derived
Inherited Members

Constructors

SpriteRenderer(Texture2D?)

Initializes a new instance of the SpriteRenderer class with the given texture.

public SpriteRenderer(Texture2D? texture)

Parameters

texture Texture2D

The Microsoft.Xna.Framework.Graphics.Texture2D to render.

Properties

Color

Gets or sets the color tint applied to the sprite.

public Color Color { get; set; }

Property Value

Color

Remarks

Default is Microsoft.Xna.Framework.Color.White.

Layer

Gets or sets the sorting depth of the sprite.

public float Layer { get; set; }

Property Value

float

Offset

Gets or sets the rendering offset.

public Point Offset { get; set; }

Property Value

Point

Origin

Gets or sets the origin of the sprite in texture coordinates. Rotation and scaling occur around this point.

public Vector2 Origin { get; set; }

Property Value

Vector2

Rotation

Gets or sets the rotation of the sprite in radians.

public float Rotation { get; set; }

Property Value

float

Scale

Gets or sets the scale of the sprite.

public float Scale { get; set; }

Property Value

float

SpriteEffects

Gets or sets the SpriteEffects.

public SpriteEffects SpriteEffects { get; set; }

Property Value

SpriteEffects

Texture

Gets or sets the texture.

public Texture2D Texture { get; set; }

Property Value

Texture2D

Remarks

Setting this property automatically sets the Origin to the center of the new texture.

Methods

Draw(SpriteBatch)

Draws the sprite to the screen if a texture is assigned.

protected override void Draw(SpriteBatch spriteBatch)

Parameters

spriteBatch SpriteBatch

Microsoft.Xna.Framework.Graphics.SpriteBatch