Skip to content

Instantly share code, notes, and snippets.

@novln
Created November 12, 2012 18:36
Show Gist options
  • Save novln/4061052 to your computer and use it in GitHub Desktop.
Save novln/4061052 to your computer and use it in GitHub Desktop.
-----
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