1

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

//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?任何帮助将不胜感激,谢谢!

4

0 回答 0