DragTrigger Movement Property Delta Engine Documentation

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

public Vector2D Movement { get; set; }

Property Value

Type: Vector2D

Implements

MovementTrigger Movement
Remarks

Tests: DeltaEngine.Input.Tests.MouseDragTriggerTests
Remarks

Tests: DeltaEngine.Input.Tests.MouseMovementTriggerTests
Examples

1 unit tests call DeltaEngine.Commands.DragTrigger.Movement
[Test]
public void DragMouseVertically()
{
    if (!IsMockResolver)
        return; //ncrunch: no coverage 
    var mouse = (MockMouse)Resolve<Mouse>();
    var trigger = new MouseDragTrigger(MouseButton.Left, DragDirection.Vertical);
    new Command(() => {}).Add(trigger);
    mouse.SetNativePosition(new Vector2D(0.3f, ScreenSpace.Current.Top + 0.1f));
    mouse.SetButtonState(MouseButton.Left, State.Pressing);
    AdvanceTimeAndUpdateEntities();
    mouse.SetNativePosition(new Vector2D(0.3f, ScreenSpace.Current.Bottom - 0.1f));
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(mouse.Position, trigger.Movement);
    mouse.SetButtonState(MouseButton.Left, State.Releasing);
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(trigger.DoneDragging);
}
Examples

2 unit tests call DeltaEngine.Commands.DragTrigger.Movement
[Test, CloseAfterFirstFrame]
public void Create()
{
    var trigger = new MouseMovementTrigger();
    Assert.AreEqual(Vector2D.Zero, trigger.Movement);
    Assert.IsFalse(trigger.IsPauseable);
}
[Test, CloseAfterFirstFrame]
public void CreateFromAttributes()
{
    var trigger = new MouseMovementTrigger(new Dictionary<string, string>());
    Assert.AreEqual(Vector2D.Zero, trigger.Movement);
    Assert.Throws<MouseMovementTrigger.MouseMovementTriggerHasNoParameters>(
        () => new MouseMovementTrigger(new Dictionary<string, string> { { "a", "b" } }));
}
See Also