一次使用多个按钮?动作

时间:2014-07-12 03:40:02

标签: android actionscript-3

我目前正在开发一款使用Action脚本为Android手机或桌面构建的游戏,我正在寻找一种同时点击两个按钮的方法。或者换句话说,按住并按住移动按钮,然后按下/轻敲触发按钮。

这是我到目前为止所拥有的。它目前上下移动角色并射击

import flash.events.MouseEvent;

var shootCheck:Boolean = false;

Shoot_btn.addEventListener(MouseEvent.CLICK,Click);
UP_mc.addEventListener(MouseEvent.MOUSE_DOWN, uparrowDown);
UP_mc.addEventListener(MouseEvent.MOUSE_UP, uparrowUp);

DOWN_mc.addEventListener(MouseEvent.MOUSE_DOWN, downarrowDown);
DOWN_mc.addEventListener(MouseEvent.MOUSE_UP, downarrowUp);

this.addEventListener(MouseEvent.MOUSE_OUT, removehandle1);
this.addEventListener(MouseEvent.MOUSE_OUT, removehandle2);

function uparrowDown(e:MouseEvent):void
{
    addEventListener(Event.ENTER_FRAME,upEnter);
}

function upEnter(e:Event):void
{
    Player_mc.y = Player_mc.y - 10;
}
function uparrowUp(e:MouseEvent):void
{
    removeEventListener(Event.ENTER_FRAME, upEnter);
}

function downarrowDown(e:MouseEvent):void
{
    addEventListener(Event.ENTER_FRAME,downEnter);
}
function downEnter(e:Event):void
{
    Player_mc.y = Player_mc.y + 10;
}
function downarrowUp(e:MouseEvent):void
{

    removeEventListener(Event.ENTER_FRAME, downEnter);
}

function removehandle1(e:MouseEvent):void
{
    removeEventListener(Event.ENTER_FRAME, upEnter);
}
function removehandle2(e:MouseEvent):void
{
    removeEventListener(Event.ENTER_FRAME, downEnter);
}

function Click(event:MouseEvent):void
{
    var bull:Bullet = new Bullet();
    addChild(bull);
    bull.x = Player_mc.x + 60;
    bull.y = Player_mc.y + Player_mc.height / 4;
    var beweeg:Function = function(evt:Event)
        {
                bull.x +=  15;
        };
        bull.addEventListener(Event.ENTER_FRAME,beweeg);
}

基于有限信息的任何帮助将不胜感激,感谢您的时间。

1 个答案:

答案 0 :(得分:0)

也许你可以通过使用getCurrentTimeInMillis()来构建一个能够获得按下按钮的确切时间的机制, 当按下下一个按钮时,它会再次花费时间。现在你可以检查两次按下之间的时间是否非常接近,如果这两个按钮与你想要执行的某个动作有关。