示例#1
0
    public override void OnTouchMove(Game game, TouchEventArgs e)
    {
        float one = 1;

        if (e.GetId() == touchIdMove)
        {
            float range = game.Width() * one / 20;
            game.touchMoveDx = e.GetX() - touchMoveStartX;
            game.touchMoveDy = -((e.GetY() - 1) - touchMoveStartY);
            float length = game.Length(game.touchMoveDx, game.touchMoveDy, 0);
            if (e.GetY() < game.Height() * 50 / 100)
            {
                game.touchMoveDx = 0;
                game.touchMoveDy = 1;
            }
            else
            {
                if (length > 0)
                {
                    game.touchMoveDx /= length;
                    game.touchMoveDy /= length;
                }
            }
        }
        if (e.GetId() == touchIdRotate)
        {
            game.touchOrientationDx += (e.GetX() - touchRotateStartX) / (game.Width() * one / 40);
            game.touchOrientationDy += (e.GetY() - touchRotateStartY) / (game.Width() * one / 40);
            touchRotateStartX        = e.GetX();
            touchRotateStartY        = e.GetY();
        }
    }
示例#2
0
 public void HandleTouchStart(TouchEventArgs e)
 {
     touchId        = e.GetId();
     previousTouchX = e.GetX();
     previousTouchY = e.GetY();
     screen.OnTouchStart(e);
 }
示例#3
0
 public override void OnTouchEnd(Game game_, TouchEventArgs e)
 {
     ScreenOnTouchEnd(e);
     if (e.GetHandled())
     {
         return;
     }
     if (e.GetId() == touchIdMove)
     {
         touchIdMove      = -1;
         game.touchMoveDx = 0;
         game.touchMoveDy = 0;
     }
     if (e.GetId() == touchIdRotate)
     {
         touchIdRotate           = -1;
         game.touchOrientationDx = 0;
         game.touchOrientationDy = 0;
     }
 }
示例#4
0
 public override void OnTouchStart(Game game_, TouchEventArgs e)
 {
     touchButtonsEnabled = true;
     ScreenOnTouchStart(e);
     if (e.GetHandled())
     {
         return;
     }
     if (e.GetX() <= game.Width() / 2)
     {
         if (touchIdMove == -1)
         {
             touchIdMove      = e.GetId();
             touchMoveStartX  = e.GetX();
             touchMoveStartY  = e.GetY();
             game.touchMoveDx = 0;
             if (e.GetY() < game.Height() * 50 / 100)
             {
                 game.touchMoveDy = 1;
             }
             else
             {
                 game.touchMoveDy = 0;
             }
         }
     }
     if (((touchIdMove != -1) &&
          (e.GetId() != touchIdMove)) ||
         (e.GetX() > game.Width() / 2))
     {
         if (touchIdRotate == -1)
         {
             touchIdRotate     = e.GetId();
             touchRotateStartX = e.GetX();
             touchRotateStartY = e.GetY();
         }
     }
 }
示例#5
0
    public void HandleTouchMove(TouchEventArgs e)
    {
        screen.OnTouchMove(e);
        if (e.GetId() != touchId)
        {
            return;
        }
        float dx = e.GetX() - previousTouchX;
        float dy = e.GetY() - previousTouchY;

        previousTouchX = e.GetX();
        previousTouchY = e.GetY();

        ySpeed += dx / 10;
        xSpeed += dy / 10;
    }
示例#6
0
 public void HandleTouchStart(TouchEventArgs e)
 {
     touchId = e.GetId();
     previousTouchX = e.GetX();
     previousTouchY = e.GetY();
     screen.OnTouchStart(e);
 }
示例#7
0
    public void HandleTouchMove(TouchEventArgs e)
    {
        screen.OnTouchMove(e);
        if (e.GetId() != touchId)
        {
            return;
        }
        float dx = e.GetX() - previousTouchX;
        float dy = e.GetY() - previousTouchY;
        previousTouchX = e.GetX();
        previousTouchY = e.GetY();

        ySpeed += dx / 10;
        xSpeed += dy / 10;
    }
 public override void OnTouchStart(Game game_, TouchEventArgs e)
 {
     touchButtonsEnabled = true;
     ScreenOnTouchStart(e);
     if (e.GetHandled()) { return; }
     if (e.GetX() <= game.Width() / 2)
     {
         if (touchIdMove == -1)
         {
             touchIdMove = e.GetId();
             touchMoveStartX = e.GetX();
             touchMoveStartY = e.GetY();
             game.touchMoveDx = 0;
             if (e.GetY() < game.Height() * 50 / 100)
             {
                 game.touchMoveDy = 1;
             }
             else
             {
                 game.touchMoveDy = 0;
             }
         }
     }
     if (((touchIdMove != -1)
         && (e.GetId() != touchIdMove))
         || (e.GetX() > game.Width() / 2))
     {
         if (touchIdRotate == -1)
         {
             touchIdRotate = e.GetId();
             touchRotateStartX = e.GetX();
             touchRotateStartY = e.GetY();
         }
     }
 }
 public override void OnTouchMove(Game game, TouchEventArgs e)
 {
     float one = 1;
     if (e.GetId() == touchIdMove)
     {
         float range = game.Width() * one / 20;
         game.touchMoveDx = e.GetX() - touchMoveStartX;
         game.touchMoveDy = -((e.GetY() - 1) - touchMoveStartY);
         float length = game.Length(game.touchMoveDx, game.touchMoveDy, 0);
         if (e.GetY() < game.Height() * 50 / 100)
         {
             game.touchMoveDx = 0;
             game.touchMoveDy = 1;
         }
         else
         {
             if (length > 0)
             {
                 game.touchMoveDx /= length;
                 game.touchMoveDy /= length;
             }
         }
     }
     if (e.GetId() == touchIdRotate)
     {
         game.touchOrientationDx += (e.GetX() - touchRotateStartX) / (game.Width() * one / 40);
         game.touchOrientationDy += (e.GetY() - touchRotateStartY) / (game.Width() * one / 40);
         touchRotateStartX = e.GetX();
         touchRotateStartY = e.GetY();
     }
 }
 public override void OnTouchEnd(Game game_, TouchEventArgs e)
 {
     ScreenOnTouchEnd(e);
     if (e.GetHandled()) { return; }
     if (e.GetId() == touchIdMove)
     {
         touchIdMove = -1;
         game.touchMoveDx = 0;
         game.touchMoveDy = 0;
     }
     if (e.GetId() == touchIdRotate)
     {
         touchIdRotate = -1;
         game.touchOrientationDx = 0;
         game.touchOrientationDy = 0;
     }
 }