多点触控和 Adob​​e AIR for Mobile

发布于 2024-12-24 01:16:33 字数 457 浏览 2 评论 0原文

我正在使用 Adob​​e AIR 3.0 开发一款 Android 游戏,我也使用 Samsung Galaxy S2 来测试我的游戏,并且运行良好,帧速率达到 30 fps。

为了控制游戏,我使用虚拟操纵杆和屏幕上的一些按钮(例如投掷武器、跳跃等)。

然而,如果我按下一个按钮并同时按下另一个按钮,多点触控似乎无法正常工作。第一个停止工作。

这是定义多点触控行为的代码片段 -

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

对于跳跃按钮、虚拟操纵杆等 - 我正在使用 TouchEvent.TOUCH_BEGIN 事件。 请让我知道触摸事件出了什么问题。

I am developing a game for Android using Adobe AIR 3.0, also i am using Samsung Galaxy S2 to test my game, and is running pretty well with decent 30 fps.

to control the game-play, i am using virtual joystick and some button on screen (e.g. to throw weapon, jump etc).

however it seems that multitouch is not working fine, if i press one button and and in the same time if i down another button. first one stops working.

here is the code snippet which defines multitouch behavior -

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

for jump button, virtual joystick etc - i am using TouchEvent.TOUCH_BEGIN event.
please let me know what is wrong with touch event.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无声情话 2024-12-31 01:16:33

一般来说,每个触摸事件都会分配一个touchPointID,并且这个touchPointID将通过它自己的TOUCH_BEGIN、TOUCH_MOVE和TOUCH_END保持一致。如果您最终根据错误的触摸点取消触摸事件,结果可能永远不会发生。请参阅 Adobe tuts 处理与touchPointID

但是,您必须发布代码才能知道到底发生了什么。

In general, a touchPointID is assigned to every touch event, and this touchPointID will be consistent through it's own TOUCH_BEGIN, TOUCH_MOVE, and TOUCH_END. If you end up cancelling the touch event based on the wrong touch point, the results may never occur. See the Adobe tuts dealing with touchPointID.

However, you will have to post your code to know what is really happening.

浴红衣 2024-12-31 01:16:33

http://flex.org/tour-de-mobile-flex/ 值得退房。这对我很有帮助。

来自 MultiTouch.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark">

  <fx:Script>
    import mx.core.UIComponent;
    import spark.components.Label;

    private var circles:Object = new Object();
  </fx:Script>

  <fx:Declarations>
    <fx:Component className="Circle">
      <s:Ellipse width="140" height="140">
        <s:fill>
          <s:SolidColor color="#ff0000"/>
        </s:fill>
      </s:Ellipse>
    </fx:Component>
  </fx:Declarations>

  <s:creationComplete>
      Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

      if (Multitouch.supportsTouchEvents)
      {
        l.text = "maxTouchPoints = " + Multitouch.maxTouchPoints;

        addEventListener(TouchEvent.TOUCH_BEGIN, function(event:TouchEvent):void {
          var c:Circle = new Circle();
          c.x = event.localX - 70;
          c.y = event.localY - 70;
          addElement(c);
          circles[event.touchPointID] = c;
        });
        addEventListener(TouchEvent.TOUCH_MOVE, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            circles[event.touchPointID].x = event.localX - 70;
            circles[event.touchPointID].y = event.localY - 70;
          }
        });
        addEventListener(TouchEvent.TOUCH_END, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            removeElement(circles[event.touchPointID]);
            delete circles[event.touchPointID];
          }
        });
        addEventListener(TouchEvent.TOUCH_OUT, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            removeElement(circles[event.touchPointID]);
            delete circles[event.touchPointID];
          }
        });
      }
      else
      {
        l.text = "MultiTouch is not supported on this device";
      }
  </s:creationComplete>

  <s:Label id="l" paddingTop="10"/>

</s:Group>

http://flex.org/tour-de-mobile-flex/ is worth checking out. It has been helpful to me.

From the MultiTouch.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
         xmlns:s="library://ns.adobe.com/flex/spark">

  <fx:Script>
    import mx.core.UIComponent;
    import spark.components.Label;

    private var circles:Object = new Object();
  </fx:Script>

  <fx:Declarations>
    <fx:Component className="Circle">
      <s:Ellipse width="140" height="140">
        <s:fill>
          <s:SolidColor color="#ff0000"/>
        </s:fill>
      </s:Ellipse>
    </fx:Component>
  </fx:Declarations>

  <s:creationComplete>
      Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

      if (Multitouch.supportsTouchEvents)
      {
        l.text = "maxTouchPoints = " + Multitouch.maxTouchPoints;

        addEventListener(TouchEvent.TOUCH_BEGIN, function(event:TouchEvent):void {
          var c:Circle = new Circle();
          c.x = event.localX - 70;
          c.y = event.localY - 70;
          addElement(c);
          circles[event.touchPointID] = c;
        });
        addEventListener(TouchEvent.TOUCH_MOVE, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            circles[event.touchPointID].x = event.localX - 70;
            circles[event.touchPointID].y = event.localY - 70;
          }
        });
        addEventListener(TouchEvent.TOUCH_END, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            removeElement(circles[event.touchPointID]);
            delete circles[event.touchPointID];
          }
        });
        addEventListener(TouchEvent.TOUCH_OUT, function(event:TouchEvent):void {
          if (circles[event.touchPointID] != null)
          {
            removeElement(circles[event.touchPointID]);
            delete circles[event.touchPointID];
          }
        });
      }
      else
      {
        l.text = "MultiTouch is not supported on this device";
      }
  </s:creationComplete>

  <s:Label id="l" paddingTop="10"/>

</s:Group>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文