本文整理汇总了C#中Microsoft.Xna.Framework.Input.Touch.GestureSample类的典型用法代码示例。如果您正苦于以下问题:C# GestureSample类的具体用法?C# GestureSample怎么用?C# GestureSample使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GestureSample类属于Microsoft.Xna.Framework.Input.Touch命名空间,在下文中一共展示了GestureSample类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTouch
public new bool ProcessTouch(GestureSample gesture)
{
Point localGesturePoint = Spotlight.TranslateScreenVectorToWorldPoint(gesture.Position);
if (!CanRespond()) return false;
if (RespondsToWorldTouch(localGesturePoint) || IsFirstResponder())
{
switch (gesture.GestureType)
{
case GestureType.FreeDrag:
SetCenter(localGesturePoint);
BecomeFirstResponder();
break;
case GestureType.DragComplete:
ResignFirstResponder();
break;
default:
return false;
}
return true;
}
return false;
}
示例2: InteractGesture
public bool InteractGesture(GestureSample gesture)
{
bool ret = false;
ret |= m_centerButton.InteractGesture(gesture);
ret |= m_contextMenu.InteractGesture(gesture);
return ret;
}
示例3: ProcessTouch
/// <summary>
/// Process a touch gesture and return an indicator of whether or not the user has advanced past this cutscene.
/// This is abberant behavior from our usual application paradigm because a cutscene it treated as a special case.
/// </summary>
/// <param name="gesture"></param>
/// <returns>true if the user has touched the Continue button. False otherwise. </returns>
public override bool ProcessTouch(GestureSample gesture)
{
if (continueButton.ProcessTouch(gesture))
{
return true;
}
switch (gesture.GestureType)
{
case GestureType.FreeDrag:
offset -= gesture.Delta;
motionTarget = Vector2.Zero;
EnforceBoundaries();
return false;
case GestureType.Flick:
Vector2 normal = gesture.Delta;
normal.Normalize();
motionTarget = offset - (normal * 200);
return false;
case GestureType.Tap:
motionTarget = Vector2.Zero;
return false;
default:
return false;
}
}
示例4: RespondToTouch
public void RespondToTouch(GestureSample gesture)
{
//if (gesture.GestureType == GestureType.Flick)
//{
// var move = new Vector2(MathHelper.Clamp(gesture.Delta.X, -flickLimit, flickLimit), MathHelper.Clamp(gesture.Delta.Y, -flickLimit, flickLimit));
// Body.ApplyLinearImpulse(ConvertUnits.ToSimUnits(move * 50));
//}
if (gesture.GestureType == GestureType.Tap)
{
if (currentJumpCount >= consecutiveJumps)
{
//return;
}
lastJumpTime = DateTime.Now;
currentJumpCount++;
if (!isOnGround)
{
//Body.ResetDynamics();
}
sphere.Body.ApplyForce(new Vector2(0, -jumpForce));
//isOnGround = false;
}
}
示例5: Update
public static void Update()
{
m_Gesture = TouchPanel.IsGestureAvailable ? TouchPanel.ReadGesture() : new GestureSample();
if (CurrentTouchCollection.Count > 0)
{
OldTouchCollection = CurrentTouchCollection;
}
CurrentTouchCollection = TouchPanel.GetState();
if (CurrentTouchCollection.Count > 0)
{
while (TouchPanel.IsGestureAvailable)
{
TouchPanel.ReadGesture();
}
}
#if !Windows
m_LastKeyboardState = m_CurrentKeyboardState;
m_CurrentKeyboardState = Keyboard.GetState();
m_LastMouseState = m_CurrentMouseState;
m_CurrentMouseState = Mouse.GetState();
#endif
}
示例6: InteractGesture
public bool InteractGesture(GestureSample gesture)
{
foreach (TextScreenObject contextMenuItem in m_contextMenuItems)
if (contextMenuItem.InteractGesture(gesture))
return true;
return false;
}
示例7: GestureDefinition
public GestureDefinition(GestureType theGestureType, Rectangle theGestureArea)
{
Gesture = new GestureSample(theGestureType, new TimeSpan(0),
Vector2.Zero, Vector2.Zero,
Vector2.Zero, Vector2.Zero);
Type = theGestureType;
CollisionArea = theGestureArea;
}
示例8: ProcessTouch
public new bool ProcessTouch(GestureSample gesture)
{
if (gesture.GestureType != GestureType.FreeDrag) return false;
if (hidden || !Contains(gesture.Position)) return false;
SetCenter(gesture.Position);
return true;
}
示例9: InteractGesture
public void InteractGesture(GestureSample gesture)
{
if (gesture.GestureType == GestureType.Tap
&& gesture.Position.X < m_textPosition.X + WarlockGame.m_spriteFont.MeasureString(m_buttonText).X && gesture.Position.X > m_textPosition.X
&& gesture.Position.Y < m_textPosition.Y + WarlockGame.m_spriteFont.MeasureString(m_buttonText).Y && gesture.Position.Y > m_textPosition.Y)
{
Execute();
}
}
示例10: ProcessTouch
public override bool ProcessTouch(GestureSample gesture)
{
if (hidden) return false;
if (!base.ProcessTouch(gesture)) return false; //Easy out
if (gesture.GestureType != GestureType.Tap) return false;
SetSelected(true);
return true;
}
示例11: OnSingleTapConfirmed
/// <summary>
/// Process the Single Tag into a Gesture
/// </summary>
/// <param name='e'>
/// If set to <c>true</c> e.
/// </param>
public override bool OnSingleTapConfirmed(MotionEvent e)
{
if ((TouchPanel.EnabledGestures & GestureType.Tap) != 0)
{
var gs = new GestureSample(GestureType.Tap, activity.Game.TargetElapsedTime,
new Vector2(e.GetX(), e.GetY()), Vector2.Zero, Vector2.Zero, Vector2.Zero);
TouchPanel.GestureList.Enqueue(gs);
}
return base.OnSingleTapConfirmed (e);
}
示例12: Create
internal IMessage Create(GestureSample gestureSample)
{
switch (gestureSample.GestureType)
{
case GestureType.Tap:
return new Message<TapGesture>(new TapGesture(gestureSample));
}
return null;
}
示例13: ComputeVelocity
private Vector2 ComputeVelocity(GestureSample gesture)
{
Vector2 diff = _currentPosition - _startPosition;
float magnitude = Math.Min(diff.Length(), 100) * 5;
diff.Normalize();
Vector2 result = diff * magnitude;
return result;
}
示例14: InteractGesture
public bool InteractGesture(GestureSample gesture)
{
if (gesture.GestureType == GestureType.Tap
&& gesture.Position.X < ExitButton.X + WarlockGame.TextureDictionary["leavecity"].Width && gesture.Position.X > ExitButton.X
&& gesture.Position.Y < ExitButton.Y + WarlockGame.TextureDictionary["leavecity"].Height && gesture.Position.Y > ExitButton.Y)
{
Execute();
return true;
}
return false;
}
示例15: EndShooting
public Vector2 EndShooting(GestureSample gesture)
{
Vector2 velocity = ComputeVelocity(gesture);
_startShootingTime = default(TimeSpan);
_startPosition = default(Vector2);
State = GameState.Idle;
return velocity;
}