当前位置: 首页>>代码示例>>C#>>正文


C# Touch.TouchLocation类代码示例

本文整理汇总了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;
     }
 }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:33,代码来源:VirtualStick.cs

示例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;
        }
开发者ID:Otto404,项目名称:wp-xna,代码行数:32,代码来源:Motion.cs

示例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;
 }
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:7,代码来源:Touch.cs

示例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);
        }
开发者ID:hristotanchev,项目名称:PMU_Game,代码行数:28,代码来源:DPadController.cs

示例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();
 }
开发者ID:jefim,项目名称:hopeless,代码行数:7,代码来源:Background.cs

示例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);
        }
开发者ID:Ben-P-Leda,项目名称:Bopscotch-IOS,代码行数:26,代码来源:TouchProcesser.cs

示例7: Unproject

 public static TouchLocation Unproject(TouchLocation touchLocation)
 {
     return new TouchLocation(
                   touchLocation.Id,
                   touchLocation.State,
                   Unproject(touchLocation.Position));
 }
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:7,代码来源:ScreenHelper.cs

示例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);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:8,代码来源:DataGrid.cs

示例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();
        }
 }
开发者ID:patrickzip,项目名称:fries-and-furious,代码行数:8,代码来源:DestructibleBlock.cs

示例10: OnTouchMove

		public override void OnTouchMove (TouchLocation state) {
			base.OnTouchMove (state);
			if (mouseDown) {
				if (DateTime.UtcNow - lastClick >= this.Interval) {
					OnClick ();
					lastClick = DateTime.UtcNow;
				}
			}
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:9,代码来源:RepeatButton.cs

示例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);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:10,代码来源:Panel.cs

示例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));
        }
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:11,代码来源:Touch.cs

示例14: handeTouch

 public void handeTouch( TouchLocation touch )
 {
     if (this.rect.Contains((int)touch.Position.X, (int)touch.Position.Y))
     {
         pressed = true;
     }
     else
     {
         pressed = false;
     }
 }
开发者ID:naveenchandru,项目名称:aadupuli,代码行数:11,代码来源:Button.cs

示例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);
		}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:11,代码来源:Panel.cs


注:本文中的Microsoft.Xna.Framework.Input.Touch.TouchLocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。