Created
November 12, 2012 18:36
-
-
Save novln/4061052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----- | |
MotionEvent mEvent = context.pollMotion(); | |
if(mEvent != null) { | |
Input event = new Input(mEvent); | |
event(event, lastEvent); | |
lastEvent = event; | |
} | |
----- | |
public void event(final Input event, final Input lastEvent) { | |
Objects.requireNonNull(event); | |
switch(event.getKind()) { | |
case ACTION_DOWN: { | |
} | |
case ACTION_MOVE: { | |
getEventListener().move(lastEvent); | |
} | |
case ACTION_UP: { | |
getEventListener().touch(lastEvent); | |
getEventListener().move(event); | |
break; | |
} | |
default: { | |
throw new AssertionError("Unknown Event"); | |
} | |
} | |
} | |
----- | |
/** | |
* @see Game#touch(Input) | |
*/ | |
@Override | |
public boolean touch(Input i) { | |
if(getLayer().touch(i)) { | |
return true; | |
} | |
return getActivity().touch(i); | |
} | |
/** | |
* @see Game#move(Input) | |
*/ | |
@Override | |
public boolean move(Input i) { | |
if(getLayer().move(i)) { | |
return true; | |
} | |
return getActivity().move(i); | |
} | |
----- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment