Inheritance Hierarchy
DeltaEngine.Entities Entity
DeltaEngine.Entities DrawableEntity
DeltaEngine.Rendering2D Entity2D
DeltaEngine.Rendering2D HierarchyEntity2D
DeltaEngine.Physics2D PhysicalEntity2D
DeltaEngine.Rendering2D Sprite
Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The HierarchyEntity2D type exposes the following members.
Constructors
Name | Description | |
---|---|---|
HierarchyEntity2D | Initializes a new instance of the HierarchyEntity2D class | |
HierarchyEntity2D(Vector2D) | Initializes a new instance of the HierarchyEntity2D class | |
HierarchyEntity2D(Rectangle, Single) | Initializes a new instance of the HierarchyEntity2D class |
Methods
Extension Methods
Name | Description | |
---|---|---|
AffixToPhysics | (Defined by Entity2DPhysicsExtensions.) | |
StartBouncingOffScreenEdges | (Defined by Entity2DExtensions.) | |
StartFalling | (Defined by Entity2DExtensions.) | |
StartMoving | (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.) | |
Center | (Inherited from Entity2D.) | |
Children | ||
Color | (Inherited from Entity2D.) | |
DidFootprintChange | (Inherited from Entity2D.) | |
DrawArea | (Inherited from Entity2D.) | |
IsActive | (Overrides DrawableEntity IsActive.) | |
IsPauseable | (Inherited from Entity.) | |
IsVisible | (Inherited from DrawableEntity.) | |
LastColor | (Inherited from Entity2D.) | |
LastDrawArea | (Inherited from Entity2D.) | |
NumberOfComponents | (Inherited from Entity.) | |
Parent | ||
RelativePosition | ||
RelativeRotation | ||
RenderLayer | (Inherited from DrawableEntity.) | |
Rotation | (Inherited from Entity2D.) | |
RotationCenter | (Inherited from Entity2D.) | |
Size | (Inherited from Entity2D.) | |
TopLeft | (Inherited from Entity2D.) | |
UpdatePriority | (Inherited from Entity.) |
Remarks
Examples
[Test] public void PositionOfChildUpdatedRelativeToParentOnParentPositionChange() { var parentEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(Vector2D.Half, Size.Zero)); var childEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(0.4f, 0.4f, 0.1f, 0.1f)); var grandChildEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(new Vector2D(0.2f, 0.0f), Size.Zero)); parentEntity.Add(childEntity); childEntity.Add(grandChildEntity); Assert.AreEqual(new Vector2D(0.4f, 0.4f), childEntity.Center); Assert.AreEqual(new Vector2D(0.2f, 0.0f), grandChildEntity.Center); parentEntity.Center += new Vector2D(0.1f, 0.1f); Assert.IsTrue(new Vector2D(0.5f, 0.5f).IsNearlyEqual(childEntity.Center), childEntity.Center.ToString()); Assert.IsTrue(new Vector2D(-0.1f, -0.1f).IsNearlyEqual(childEntity.RelativePosition), childEntity.RelativePosition.ToString()); Assert.IsTrue(new Vector2D(0.3f, 0.1f).IsNearlyEqual(grandChildEntity.Center), grandChildEntity.Center.ToString()); Assert.IsTrue(new Vector2D(-0.2f, -0.4f).IsNearlyEqual(grandChildEntity.RelativePosition), grandChildEntity.RelativePosition.ToString()); }
[Test] public void SetLocalsUpdatesGlobals() { var parentEntity = new MockHierarchyEntity2D(Rectangle.FromCenter(Vector2D.Half, Size.Zero)); var childEntity = new MockHierarchyEntity2D(Rectangle.Zero); parentEntity.Add(childEntity); var childRelativePosition = new Vector2D(0.2f, 0.0f); childEntity.RelativePosition = childRelativePosition; childEntity.RelativeRotation = 10; Assert.AreEqual(parentEntity.Center + childRelativePosition, childEntity.Center); Assert.AreEqual(10, childEntity.Rotation); }
[Test] public void BuildHierarchyOfDifferentEntities() { var parentEntity = new MockHierarchyEntity2D(); var entityGivenPosition = new MockHierarchyEntity2D(new Vector2D(0.3f, 0.4f)); var entityGivenRect = new MockHierarchyEntity2D(new Rectangle(0.1f, 0.0f, 0.5f, 0.4f), 20); parentEntity.Add(entityGivenPosition); parentEntity.Add(entityGivenRect); Assert.AreEqual(parentEntity, entityGivenPosition.Parent); Assert.AreEqual(new Vector2D(0.3f, 0.4f), entityGivenPosition.RelativePosition); Assert.AreEqual(parentEntity, entityGivenRect.Parent); Assert.AreEqual(20, entityGivenRect.RelativeRotation); }
See Also