简体   繁体   English

多点触控和Adobe AIR for Mobile

[英]Multi touch and Adobe AIR for Mobile

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. 我正在使用Adobe AIR 3.0开发适用于Android的游戏,也正在使用Samsung Galaxy S2来测试我的游戏,并且以不错的30 fps运行得很好。

to control the game-play, i am using virtual joystick and some button on screen (eg 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. 用于跳转按钮,虚拟操纵杆等-我正在使用TouchEvent.TOUCH_BEGIN事件。 please let me know what is wrong with touch event. 请让我知道触摸事件出了什么问题。

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. 通常,将touchPointID分配给每个触摸事件,并且该touchPointID将通过其自己的TOUCH_BEGIN,TOUCH_MOVE和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 . 请参阅处理touchPointIDAdobe touchPointID

However, you will have to post your code to know what is really happening. 但是,您将必须发布代码以了解实际情况。

http://flex.org/tour-de-mobile-flex/ is worth checking out. http://flex.org/tour-de-mobile-flex/值得一试。 It has been helpful to me. 这对我很有帮助。

From the MultiTouch.mxml: 从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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM