本文整理汇总了C#中Microsoft.Xna.Framework.Input.Touch.TouchLocation类的典型用法代码示例。如果您正苦于以下问题:C# TouchLocation类的具体用法?C# TouchLocation怎么用?C# TouchLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TouchLocation类属于Microsoft.Xna.Framework.Input.Touch命名空间,在下文中一共展示了TouchLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(TouchLocation touchLocation)
{
if (touchLocation.State == TouchLocationState.Pressed && _picked < 0)
{
Vector2 delta = touchLocation.Position - _position;
if (delta.LengthSquared() <= 2025f)
{
_picked = touchLocation.Id;
}
}
if ((touchLocation.State == TouchLocationState.Pressed ||
touchLocation.State == TouchLocationState.Moved) && touchLocation.Id == _picked)
{
Vector2 delta = touchLocation.Position - _center;
if (delta != Vector2.Zero)
{
float _length = delta.Length();
if (_length > 25f)
{
delta *= (25f / _length);
}
StickPosition = delta / 25f;
StickPosition.Y *= -1f;
_position = _center + delta;
}
}
if (touchLocation.State == TouchLocationState.Released && touchLocation.Id == _picked)
{
_picked = -1;
_position = _center;
StickPosition = Vector2.Zero;
}
}
示例2: Create
internal static Motion Create( TouchLocation location, bool is8D )
{
Motion motion = new Motion ( );
switch ( location.State )
{
case TouchLocationState.Invalid:
motion.Type = MotionType.None;
break;
case TouchLocationState.Pressed:
motion.Type = MotionType.Down;
break;
case TouchLocationState.Moved:
motion.Type = MotionType.Press;
break;
case TouchLocationState.Released:
motion.Type = MotionType.Up;
break;
}
motion.Position = location.Position / World.Scale;
TouchLocation prevLocation;
if ( location.TryGetPreviousLocation ( out prevLocation ) && prevLocation.State != TouchLocationState.Invalid )
motion.Offset = ( location.Position - prevLocation.Position ) / World.Scale;
return motion;
}
示例3: Touch
public Touch(TouchLocation location)
{
this.systemTouch = location;
this.TouchID = location.Id;
this.positions.Begin = this.systemTouch.Position;
this.positions.Current = this.systemTouch.Position;
}
示例4: Update
public override void Update(GameTime gameTime)
{
_touchLocation = TouchPanel.GetState().FirstOrDefault<TouchLocation>();
if (_touchLocation.State == TouchLocationState.Pressed)
{
_intersectRect.X = (int)_touchLocation.Position.X;
_intersectRect.Y = (int)_touchLocation.Position.Y;
_intersectRect.Width = 1;
_intersectRect.Height = 1;
if (_intersectRect.Intersects(_rightRect))
PressedDirection = DpadDirection.dRIGTH;
else if (_intersectRect.Intersects(_leftRect))
PressedDirection = DpadDirection.dLEFT;
else if (_intersectRect.Intersects(_upRect))
PressedDirection = DpadDirection.dUP;
else if (_intersectRect.Intersects(_downRect))
PressedDirection = DpadDirection.dDOWN;
else
PressedDirection = DpadDirection.dNONE;
}
else if ((_touchLocation.State == TouchLocationState.Invalid) || (_touchLocation.State == TouchLocationState.Released))
PressedDirection = DpadDirection.dNONE;
base.Update(gameTime);
}
示例5: OnTouch
protected override void OnTouch(TouchLocation touch)
{
base.OnTouch(touch);
this.Direction = -1 * (touch.Position - new Vector2(Game1.ScreenWidth / 2, Game1.ScrrenHeight / 2));
this.DistanceToMove = this.Direction.Length();
this.Direction.Normalize();
}
示例6: Update
public override void Update(GameTime gameTime)
{
_touchData.Clear();
TouchCollection currentTouches = TouchPanel.GetState();
foreach (TouchLocation touchLocation in currentTouches)
{
if ((touchLocation.State != TouchLocationState.Invalid) && (touchLocation.State != TouchLocationState.Released))
{
TouchLocation previousLocationContainer = new TouchLocation();
if (touchLocation.TryGetPreviousLocation(out previousLocationContainer))
{
_touchData.Add(new Touch(
TranslatePositionFromScreenToBuffer(touchLocation.Position),
TranslatePositionFromScreenToBuffer(previousLocationContainer.Position)));
}
else
{
_touchData.Add(new Touch(
TranslatePositionFromScreenToBuffer(touchLocation.Position),
TranslatePositionFromScreenToBuffer(touchLocation.Position)));
}
}
}
base.Update(gameTime);
}
示例7: Unproject
public static TouchLocation Unproject(TouchLocation touchLocation)
{
return new TouchLocation(
touchLocation.Id,
touchLocation.State,
Unproject(touchLocation.Position));
}
示例8: OnTouchMove
public override void OnTouchMove (TouchLocation state) {
var offset = Math.Min (0, state.Position.Y - startPos);
if (-offset > (contentHeight - (this.ActualHeight - 50)))
offset = -(contentHeight - (this.ActualHeight - 50));
this.VerticalOffset = (int)offset;
base.OnTouchMove (state);
}
示例9: CheckUserTouch
public override void CheckUserTouch(TouchLocation tl)
{
if (tl.State == TouchLocationState.Pressed)
{
if (BlockHitBoxTouch.Intersects(new Rectangle((int)tl.Position.X, (int)tl.Position.Y, 1, 1)))
Destroy();
}
}
示例10: OnTouchMove
public override void OnTouchMove (TouchLocation state) {
base.OnTouchMove (state);
if (mouseDown) {
if (DateTime.UtcNow - lastClick >= this.Interval) {
OnClick ();
lastClick = DateTime.UtcNow;
}
}
}
示例11: OnTouchUp
public override void OnTouchUp (TouchLocation state) {
foreach (var c in this.Children.OfType<Control>())
if (c.IsEnabled
&& c.Opacity > 0
&& VisualTreeHelper.IsVisible ( c )
&& (c.HitTest(state.Position) || c.IsTouchDown))
c.OnTouchUp(state);
base.OnTouchUp (state);
}
示例12: Update
public void Update(TouchCollection toucheCollection, GameTime gameTime)
{
TouchLocation[] touchLocs = new TouchLocation[toucheCollection.Count];
int i = 0;
foreach (var touch in toucheCollection)
{
touchLocs[i++] = new TouchLocation(touch.Id, touch.State, orientation.Transform(touch.Position));
}
baseTC.Update(new TouchCollection(touchLocs), gameTime);
}
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:11,代码来源:OrientedTouchController.cs
示例13: UpdateLocation
internal void UpdateLocation(TouchLocation touchLocation)
{
if (this.TouchID == touchLocation.Id)
{
this.systemTouch = touchLocation;
this.positions.UpdateLocation(touchLocation.Position);
return;
}
throw new InvalidOperationException(string.Format("TouchLocation id({0}) must be matched with TouchID({1})", touchLocation.Id, TouchID));
}
示例14: handeTouch
public void handeTouch( TouchLocation touch )
{
if (this.rect.Contains((int)touch.Position.X, (int)touch.Position.Y))
{
pressed = true;
}
else
{
pressed = false;
}
}
示例15: OnTouchDown
public override void OnTouchDown (TouchLocation state) {
foreach (var c in this.Children.OfType<Control>()) {
if (c.IsEnabled
&& c.Opacity > 0 // TODO Should remove, in WPF, transparent Buttons are clickable
&& VisualTreeHelper.IsVisible ( c )
&& c.HitTest(state.Position)) {
c.OnTouchDown(state);
}
}
base.OnTouchDown (state);
}