Hello!
I am working on a game where there is a hero. The hero can jump with swipe up on the stage and he can fire with tap on the stage. Things get a little wonky and weird when I try and do some rapid fire and quick jumping. How can I optimize this to work better? Should be adding eventListeners with separate methods?
Here the code... any help MUCH appreciated.
tap.addEventListener(GestureEvent.GESTURE_STATE_CHANGE, onGesture);
swipe.addEventListener(GestureEvent.GESTURE_STATE_CHANGE, onGesture);
private function onGesture(event:GestureEvent):void
{
trace(event.target+ event.newState.toString());
if(event.target == tap){
if(event.type == "gestureRecognized"){
bulletManager.fire();
}
}else if(event.target == swipe){
if(event.type == "gestureRecognized"){
heroJump(event);
swipe.removeEventListener(GestureEvent.GESTURE_RECOGNIZED, onGesture);
}else if(event.type == "gestureIdle"){
swipe.addEventListener(GestureEvent.GESTURE_RECOGNIZED, onGesture);
}
}
}
Hello!
I am working on a game where there is a hero. The hero can jump with swipe up on the stage and he can fire with tap on the stage. Things get a little wonky and weird when I try and do some rapid fire and quick jumping. How can I optimize this to work better? Should be adding eventListeners with separate methods?
Here the code... any help MUCH appreciated.