我正在尝试为Android创建一个简单的应用程序,在这里你可以侧身寻找不同的对象来点击。当您单击它们消失的对象时,您将获得分数。
我已设法为点击和平移创建单独的代码,但如果你平移,则无法点击该对象。如果您在平移之前单击该对象,则所有操作都像魅力一样。
平移代码:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
Game_Background1.addEventListener(TransformGestureEvent.GESTURE_PAN, swipe_pan);
function swipe_pan(event:TransformGestureEvent):void
{
event.currentTarget.x += event.offsetX;
event.currentTarget.y +0; event.offsetY;
}
点击代码:
Multitouch.inputMode = MultitouchInputMode.GESTURE;
Bunny.addEventListener(PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP, hideBunny);
function hideBunny(event:PressAndTapGestureEvent):void
{
Bunny.visible = false;
Bunny.alpha *= 0.5;
}
点击代码位于同一动画片段中的动作图层中,与具有可点击对象的图层位于“Bunny”中。
然后,平移代码位于该动画片段外部的动作图层中。
感谢我对此有任何帮助。
答案 0 :(得分:0)
我建议您尝试Gestouch
尝试类似:
var panGenture:PanGesture;
panGenture = new PanGesture(Bunny);
panGenture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onPanHandler);
panGenture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onPanHandler);
function onPanHandler(event:org.gestouch.events.GestureEvent):void
{
trace("pan");
}
或
var tapGesture:TapGesture;
tapGesture = new TapGesture(Bunny);
tapGesture.addEventListener(org.gestouch.events.GestureEvent.GESTURE_RECOGNIZED, onGestureHandler);
//you can also add tapGesture.numTapsRequired = 2;
function onGestureHandler(event:org.gestouch.events.GestureEvent):void
{
trace("tap");
}