1
votes

I am developing a game for Android, and in future IOS and I need to be able to move the player with a left or right on screen control as well as have the player able to shoot simultaneously with another on screen control.

As it is I have it set up with MouseEvent.CLICK which works, but only one at a time. I have tried replacing my MouseEvent.CLICK listeners with TouchEvent.TOUCH_BEGIN and adding a TouchEvent.TOUCH_END and setting Multitouch.inputMode = multitouchInputMode.TOUCH_POINT, but I realize in documentation TOUCH_POINT doesn't allow for multiple touch inputs so I am left to using GESTURE. I have no idea where to start with implementing this to allow for me to be able to have two buttons pressed simultaneously.

Code snippet:

leftControl = new Left_btn(50,430);
rightControl = new Right_btn(150,430);
dropControl = new Drop_btn(750,430);
stage.addChild(leftControl);
stage.addChild(rightControl);
stage.addChild(dropControl);
leftControl.addEventListener(TouchEvent.TOUCH_BEGIN,player.moveLeft);
leftControl.addEventListener(TouchEvent.TOUCH_END,player.moveLeftStop);
rightControl.addEventListener(TouchEvent.TOUCH_BEGIN,player.moveRight);
rightControl.addEventListener(TouchEvent.TOUCH_END,player.moveRightStop);
dropControl.addEventListener(TouchEvent.TOUCH_TAP,player.drop);

I also have a problem when using the buttons even without any listeners added. The whole game lags for a frame or so when taping or clicking on a button. Not sure why or how to fix this.

EDIT: By replacing the buttons with movieclips, this seems to have stopped the frame lag.

1

1 Answers

0
votes

Frame lagging is a major issue with Air and iOS, even on Android. You have to maintain your code for optimization.

For Multitouch try this, Tap, Gesture and Multitouch

To directly access iOS Touch APIs try with,

ANE Air Native Extension