控制角色时触摸事件上的错误

时间:2013-09-10 04:40:25

标签: actionscript-3 multi-touch flashdevelop touch-event

嘿伙计们,所以我已经坚持了一段时间,并认为我最终会寻求一些帮助。所以基本上我有一个由这些触摸事件处理的角色:

//setup Listeners when btn's touch begin and end
        btnUp.addEventListener(TouchEvent.TOUCH_BEGIN, btnUpMouseOver, false, 0, true); 
        btnUp.addEventListener(TouchEvent.TOUCH_END, btnUpMouseOver, false, 0, true);
        btnDown.addEventListener(TouchEvent.TOUCH_BEGIN, btnDownMouseOver, false, 0, true); 
        btnDown.addEventListener(TouchEvent.TOUCH_END, btnDownMouseOver, false, 0, true);




private function btnDownMouseOver(e:TouchEvent):void 
    {
        //trace("btnDownRollover");
        if (e.type == TouchEvent.TOUCH_BEGIN)
          {
              //Mouse was pressed on this button
             btnPressedDown = true;

          }
          else if(e.type == TouchEvent.TOUCH_END)
          {
              //Mouse was released
              btnPressedDown = false;
          }
    }

    private function btnUpMouseOver(e:TouchEvent):void 
    {
        //trace("btnUpRollOver");
          if (e.type == TouchEvent.TOUCH_BEGIN)
          {
              //Mouse was pressed on this button
              btnPressedUp = true;



          }
          else if(e.type == TouchEvent.TOUCH_END)
          {
              //Mouse was released
              btnPressedUp = false;
          }
    }

现在一切正常。当我按下按钮向上或向下移动角色时,它们会完美响应。但是我修复时遇到的问题就是当人们按下按钮以向上或向下移动角色而不是按下按钮时角色飞到舞台的顶部并且卡住我仍然可以控制但是第二个我释放按钮它向上或向下飞行取决于人是否向上或向下滑动按钮。你能看到我在这里做错什么吗?也许我应该使用像TOUCH_MOVE或TOUCH_OUT这样的东西?非常感谢,谢谢!

0 个答案:

没有答案