void HandleTouchBegin3(TouchBeginEventArgs args)
        {
            var            graphics     = Graphics;
            PhysicsWorld2D physicsWorld = scene.GetComponent <PhysicsWorld2D>();
            RigidBody2D    rigidBody    = physicsWorld.GetRigidBody(new Vector2(args.X, args.Y), uint.MaxValue); // Raycast for RigidBody2Ds to pick

            if (rigidBody != null)
            {
                pickedNode = rigidBody.Node;
                StaticSprite2D staticSprite = pickedNode.GetComponent <StaticSprite2D>();
                staticSprite.Color = (new Color(1.0f, 0.0f, 0.0f, 1.0f)); // Temporary modify color of the picked sprite
                rigidBody          = pickedNode.GetComponent <RigidBody2D>();

                // Create a ConstraintMouse2D - Temporary apply this constraint to the pickedNode to allow grasping and moving with touch
                ConstraintMouse2D constraintMouse = pickedNode.CreateComponent <ConstraintMouse2D>();
                Vector3           pos             = camera.ScreenToWorldPoint(new Vector3((float)args.X / graphics.Width, (float)args.Y / graphics.Height, 0.0f));
                constraintMouse.Target           = new Vector2(pos.X, pos.Y);
                constraintMouse.MaxForce         = 1000 * rigidBody.Mass;
                constraintMouse.CollideConnected = true;
                constraintMouse.OtherBody        = dummyBody; // Use dummy body instead of rigidBody. It's better to create a dummy body automatically in ConstraintMouse2D
                constraintMouse.DampingRatio     = 0;
            }

            touchMoveEventToken = Input.SubscribeToTouchMove(HandleTouchMove3);
            touchEndEventToken  = Input.SubscribeToTouchEnd(HandleTouchEnd3);
        }
示例#2
0
        protected override void TouchBegin(TouchBeginEventArgs e)
        {
            if (!UIPressed)
            {
                activeTouches.Add(e.TouchID, new Vector2(e.X, e.Y));

                var clickedRay = cameraMover.Camera.GetScreenRay(e.X / (float)UI.Root.Width,
                                                                 e.Y / (float)UI.Root.Height);

                if (DoOnlySingleRaycasts)
                {
                    var raycastResult = octree.RaycastSingle(clickedRay);
                    if (raycastResult.HasValue)
                    {
                        //levelManager.HandleRaycast(Player, raycastResult.Value);
                    }
                }
                else
                {
                    var raycastResults = octree.Raycast(clickedRay);
                    if (raycastResults.Count != 0)
                    {
                        //levelManager.HandleRaycast(Player, raycastResults);
                    }
                }
            }
            else
            {
                UIPressed = false;
            }
        }
示例#3
0
        private void OnTouchBegin(TouchBeginEventArgs e)
        {
            var x = (float)e.X / Graphics.Width;
            var y = (float)e.Y / Graphics.Height;

            DetermineHit(x, y);
        }
        public void OnTouchBegan(TouchBeginEventArgs eventArgs)
        {
            // Fill out variables for tap gesture
            tapTouchID   = eventArgs.TouchID;
            tapTimeStamp = Time.ElapsedTime;

            currentScreenLayout.OnTouchBegan(eventArgs);
        }
示例#5
0
 private void HandleTouchBegin(TouchBeginEventArgs args)
 {
     StartTouch(new TouchState
     {
         ID             = args.TouchID,
         ScreenPosition = new IntVector2(args.X, args.Y),
         Pressure       = args.Pressure
     });
 }
示例#6
0
        private void Input_TouchBegin(TouchBeginEventArgs obj)
        {
            Debug.WriteLine($"Input_TouchBegin {obj.X},{obj.Y}");

            Ray cameraRay = Camera.GetScreenRay((float)obj.X / Graphics.Width, (float)obj.Y / Graphics.Height);
            var results   = Octree.Raycast(cameraRay, RayQueryLevel.Triangle, 100, DrawableFlags.Geometry);

            TouchedNode = results.Select(x => x.Node).FirstOrDefault();

            if (TouchedNode != null)
            {
                Debug.WriteLine($"Input Touch");
            }
        }
示例#7
0
 public TouchBeginEventArguments(TouchBeginEventArgs args) : base(args)
 {
     Pressure = args.Pressure;
 }
示例#8
0
 protected override void TouchBegin(TouchBeginEventArgs e)
 {
 }
示例#9
0
		void Input_TouchBegin(TouchBeginEventArgs e)
		{
			touchStarted = DateTime.UtcNow;
		}
 private void OnTouchBegin(TouchBeginEventArgs args)
 {
     _touchBegin?.Invoke(this, new TouchBeginEventArguments(args));
 }
示例#11
0
 void Input_TouchBegin(TouchBeginEventArgs e)
 {
     touchStarted = DateTime.UtcNow;
 }
示例#12
0
 void InputOnTouchBegin(TouchBeginEventArgs touchBeginEventArgs)
 {
 }
示例#13
0
 public TouchEventArguments(TouchBeginEventArgs args)
 {
     TouchID = args.TouchID;
     X       = args.X;
     Y       = args.Y;
 }
示例#14
0
 private void Input_TouchBegin(TouchBeginEventArgs obj)
 {
 }
示例#15
0
 public override void OnTouchBegan(TouchBeginEventArgs eventArgs)
 {
 }
        void HandleTouchBegin3(TouchBeginEventArgs args)
        {
            var graphics = Graphics;
            PhysicsWorld2D physicsWorld = scene.GetComponent<PhysicsWorld2D>();
            RigidBody2D rigidBody = physicsWorld.GetRigidBody(new Vector2(args.X, args.Y), uint.MaxValue); // Raycast for RigidBody2Ds to pick
            if (rigidBody != null)
            {
                pickedNode = rigidBody.Node;
                StaticSprite2D staticSprite = pickedNode.GetComponent<StaticSprite2D>();
                staticSprite.Color=(new Color(1.0f, 0.0f, 0.0f, 1.0f)); // Temporary modify color of the picked sprite
                rigidBody = pickedNode.GetComponent<RigidBody2D>();

                // Create a ConstraintMouse2D - Temporary apply this constraint to the pickedNode to allow grasping and moving with touch
                ConstraintMouse2D constraintMouse = pickedNode.CreateComponent<ConstraintMouse2D>();
                Vector3 pos = camera.ScreenToWorldPoint(new Vector3((float)args.X / graphics.Width, (float)args.Y / graphics.Height, 0.0f));
                constraintMouse.Target=new Vector2(pos.X, pos.Y);
                constraintMouse.MaxForce=1000 * rigidBody.Mass;
                constraintMouse.CollideConnected=true;
                constraintMouse.OtherBody=dummyBody;  // Use dummy body instead of rigidBody. It's better to create a dummy body automatically in ConstraintMouse2D
                constraintMouse.DampingRatio=0;
            }

            touchMoveEventToken = Input.SubscribeToTouchMove(HandleTouchMove3);
            touchEndEventToken = Input.SubscribeToTouchEnd(HandleTouchEnd3);
        }
示例#17
0
 protected abstract void TouchBegin(TouchBeginEventArgs e);
 public abstract void OnTouchBegan(TouchBeginEventArgs eventArgs);
示例#19
0
 void OnTouchBegin(TouchBeginEventArgs e)
 {
     scaling = false;
 }
 public override void OnTouchBegan(TouchBeginEventArgs eventArgs)
 {
     CameraManager.EnableCameraScreens(true, Selection);
     touchThrottleTime = Time.SystemTime;
 }