Skip to content

Issues with tap and swipe. How should I optimize? #80

@BeauKelsey

Description

@BeauKelsey

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);
                }
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions