嘿伙计们,所以我有一个快速的问题。我有一个响应用户触摸的影片剪辑。它是一艘可以线性向上或向下移动的船。现在触摸事件工作正常,我通过在舞台上创建 2 个单独的电影剪辑来设置它们,这些剪辑充当控制飞船的按钮。因此,当用户触摸顶部按钮时,船会向上移动,底部按钮也是如此。顺便说一下,这款游戏适用于安卓手机。所以我的问题是我如何才能到达不需要任何电影剪辑按钮来控制船的地方?当用户向上或向下移动手指时,我无法到达触摸事件响应的位置。无需将手指从手机上移开,然后将其放在单独的按钮上。我已经在许多其他游戏中看到过这种情况,如果您在手指仍在手机上时向上或向下移动它,它会响应它并朝正确的方向移动。
//setup Listeners when btn's are rolled over and out
btnUp.addEventListener(TouchEvent.TOUCH_OVER, btnUpMouseOver, false, 0, true);
btnUp.addEventListener(TouchEvent.TOUCH_OUT, btnUpMouseOver, false, 0, true);
btnDown.addEventListener(TouchEvent.TOUCH_OVER, btnDownMouseOver, false, 0, true);
btnDown.addEventListener(TouchEvent.TOUCH_OUT, btnDownMouseOver, false, 0, true);
shootPlayer.addEventListener(TouchEvent.TOUCH_TAP, shootPlayerObject, false, 0, true);
那么我有以下功能:
private function btnDownMouseOver(e:TouchEvent):void
{
//trace("btnDownRollover");
if (e.type == TouchEvent.TOUCH_OVER)
{
//Mouse was pressed on this button
btnPressedDown = true;
}
else
{
//Mouse was released
btnPressedDown = false;
}
}
private function btnUpMouseOver(e:TouchEvent):void
{
//trace("btnUpRollOver");
if (e.type == TouchEvent.TOUCH_OVER)
{
//Mouse was pressed on this button
btnPressedUp = true;
}
else
{
//Mouse was released
btnPressedUp = false;
}
}
所以这就是现在控制这艘船的东西。正如我上面所说,它工作正常。只是想看看他们是否有办法摆脱按钮,只要手指改变方向,就让它在向上或向下位置做出响应。任何帮助将不胜感激,谢谢!