SpriteSaveAndLoadTests CreateSpriteFromComponents Method Delta Engine Documentation

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

public void CreateSpriteFromComponents()
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);
}
See Also