HierarchyEntity2D Add Method (HierarchyObject2D)Delta Engine Documentation

Namespace: DeltaEngine.Rendering2D
Assembly: DeltaEngine.Rendering2D (in DeltaEngine.Rendering2D.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public void Add(
	HierarchyObject2D child
)

Implements

HierarchyObject2D Add(HierarchyObject2D)
Remarks

Tests: DeltaNinja.Tests.Entities.LogoTests
Examples

2 unit tests call DeltaEngine.Rendering2D.HierarchyEntity2D.Add(DeltaEngine.Entities.HierarchyObject2D)
[Test]
public void CreateLogos()
{
    var randomizer = new PseudoRandom();
    var factory = new LogoFactory(Resolve<ScreenSpace>());
    var logos = new List<Logo>();
    var n = randomizer.Get(10, 100);
    for (int i = 0; i < n; i++)
    {
        var logo = factory.Create();
        if (logo != null)
            logos.Add(logo);
    }
    Assert.IsTrue(logos.Count == n);
}
[Test, CloseAfterFirstFrame, Ignore]
public void ShowLogosAndWait()
{
    var screen = Resolve<ScreenSpace>();
    var factory = new LogoFactory(screen);
    var logos = new List<Logo>();
    var n = Randomizer.Current.Get(10, 100);
    for (int i = 0; i < n; i++)
    {
        var logo = factory.Create();
        if (logo != null)
            logos.Add(logo);
    }
    Assert.IsTrue(logos.Count == n);
    if (!IsMockResolver)
        return;
    while (GlobalTime.Current.Milliseconds < 10000)
    {
        var mouse = Resolve<MockMouse>();
        mouse.SetButtonState(MouseButton.Left, State.Releasing);
        AdvanceTimeAndUpdateEntities(1);
        if (Time.CheckEvery(1))
        {
            Resolve<Window>().Title = "Logo count: " + logos.Count;
            logos.RemoveAll(x => x.IsOutside(screen.Viewport));
        }
    }
    Assert.IsTrue(logos.Count == 0);    
}
See Also