當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。