2D sprite to be rendered, which is an image or animation or sprite sheet used as an Entity2D.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities Entity
DeltaEngine.Entities DrawableEntity
DeltaEngine.Rendering2D Entity2D
DeltaEngine.Rendering2D HierarchyEntity2D
DeltaEngine.Rendering2D Sprite
Asteroids Asteroid
Asteroids PlayerShip
Blocks Brick
Breakout Ball
Breakout Paddle
CarGame2D Car
CarGame2D Game
DeltaEngine.Scenes.Controls Control
DeltaNinja.Entities MovingSprite
DeltaNinja.UI LogoLink
FindTheWord StartupScreen
GameOfDeath FadeSprite
GameOfDeath.Items Item
GameOfDeath Rabbit
GhostWars Tree
LogoApp BouncingLogo
SideScroller Plane
TilDeath Background
TilDeath Enemy
TilDeath HeroDeath
Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Sprite type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Sprite | Initializes a new instance of the Sprite class | |
Sprite(String, Rectangle) | Initializes a new instance of the Sprite class | |
Sprite(String, Vector2D) | Initializes a new instance of the Sprite class | |
Sprite(Material, Rectangle) | Initializes a new instance of the Sprite class | |
Sprite(Material, Vector2D) | Initializes a new instance of the Sprite class |
Methods
Extension Methods
Name | Description | |
---|---|---|
AffixToPhysics | (Defined by Entity2DPhysicsExtensions.) | |
StartBouncingOffScreenEdges | (Defined by Entity2DExtensions.) | |
StartFalling | (Defined by Entity2DExtensions.) | |
StartMoving | (Defined by Entity2DExtensions.) | |
StartMovingUV | (Defined by Entity2DExtensions.) | |
StartRotating | (Defined by Entity2DExtensions.) |
Fields
Name | Description | |
---|---|---|
components | (Inherited from Entity.) | |
lastTickLerpComponents |
Each element can either be a Lerp, a Lerp List or an array of Lerp objects.
View code on GitHub (Inherited from DrawableEntity.) |
Properties
Name | Description | |
---|---|---|
Alpha | (Inherited from Entity2D.) | |
BlendMode | ||
Center | (Inherited from Entity2D.) | |
Children | (Inherited from HierarchyEntity2D.) | |
Color | (Inherited from Entity2D.) | |
CurrentFrame | ||
DidFootprintChange | (Inherited from Entity2D.) | |
DrawArea | (Inherited from Entity2D.) | |
Elapsed | ||
FlipMode | ||
IsActive | (Inherited from HierarchyEntity2D.) | |
IsPauseable | (Inherited from Entity.) | |
IsPlaying | ||
IsVisible | (Inherited from DrawableEntity.) | |
LastColor | (Inherited from Entity2D.) | |
LastDrawArea | (Inherited from Entity2D.) | |
LastUV | ||
Material | ||
NumberOfComponents | (Inherited from Entity.) | |
Parent | (Inherited from HierarchyEntity2D.) | |
RelativePosition | (Inherited from HierarchyEntity2D.) | |
RelativeRotation | (Inherited from HierarchyEntity2D.) | |
RenderLayer | (Inherited from DrawableEntity.) | |
Rotation | (Inherited from Entity2D.) | |
RotationCenter | (Inherited from Entity2D.) | |
Size | (Inherited from Entity2D.) | |
TopLeft | (Inherited from Entity2D.) | |
UpdatePriority | (Inherited from Entity.) | |
UV |
Events
Name | Description | |
---|---|---|
AnimationEnded |
Remarks
Examples
[Test, CloseAfterFirstFrame] public void CreateSpriteFromComponents() { var components = new List<object>(); components.Add(Rectangle.One); components.Add(true); var material = new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo"); components.Add(material); components.Add(material.DiffuseMap.BlendMode); components.Add(new RenderingData()); var sprite = Activator.CreateInstance(typeof(Sprite), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, null, CultureInfo.CurrentCulture) as Sprite; sprite.SetComponents(components); Assert.AreEqual(material, sprite.Material); Assert.AreEqual(Rectangle.One, sprite.DrawArea); Assert.AreEqual(material.DiffuseMap.BlendMode, sprite.BlendMode); }
[Test, CloseAfterFirstFrame] public void SaveAndLoadSprite() { var sprite = new Sprite("DeltaEngineLogo", Rectangle.One); var data = BinaryDataExtensions.SaveToMemoryStream(sprite); Assert.Greater(data.Length, 0); var loadedSprite = data.CreateFromMemoryStream() as Sprite; Assert.AreEqual(sprite.Material.Shader, loadedSprite.Material.Shader); Assert.AreEqual(sprite.Material.DiffuseMap, loadedSprite.Material.DiffuseMap); Assert.AreEqual(sprite.DrawArea, loadedSprite.DrawArea); Assert.AreEqual(sprite.BlendMode, loadedSprite.BlendMode); Assert.AreEqual(sprite.Rotation, loadedSprite.Rotation); Assert.AreEqual(1, loadedSprite.GetActiveBehaviors().Count); Assert.AreEqual(1, loadedSprite.GetDrawBehaviors().Count); Assert.AreEqual("SpriteRenderer", loadedSprite.GetDrawBehaviors()[0].GetShortNameOrFullNameIfNotFound()); }
[Test, ApproveFirstFrameScreenshot] public void RenderAnimatedSprite() { new Sprite(material, new Rectangle(0.4f, 0.4f, 0.2f, 0.2f)); }
See Also