我正在使用Adobe AIR 3.0开发适用于Android的游戏,也正在使用Samsung Galaxy S2来测试我的游戏,并且以不错的30 fps运行得很好。
为了控制游戏玩法,我正在使用虚拟操纵杆和屏幕上的某些按钮(例如,投掷武器,跳跃等)。
但是,如果我按下一个按钮,同时按下另一个按钮,似乎多点触控无法正常工作。第一个停止工作。
这是定义多点触控行为的代码段-
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
用于跳转按钮,虚拟操纵杆等-我正在使用TouchEvent.TOUCH_BEGIN事件。
请让我知道触摸事件出了什么问题。
最佳答案
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>
关于android - 多点触控和Adobe AIR for Mobile,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8697588/