I am currently working on a game built using Action-script for the android phone or table and im looking for a way to hit two buttons at the same time. Or in other words pushing and holding a movement button then pushing / tapping the firing button.
This is what i have so far. it currently moves the character up and down and shoots
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);
}
any help based off the limited info would be greatly appreciated and thank you for your time.
0 comments:
Post a Comment