Touch and Key Events

This sections shows you how to implement some basic and advanced mechanism for controlling sprites and interacting with the State.

Methods

Each State has to implement the following two methods:

1
2
3
4
5
6
7
8
9
    @Override
    public boolean onKeyEvent(View v, int keyCode, KeyEvent keyEvent) {
        return false;
    }

    @Override
    public boolean onTouchEvent(View v, MotionEvent event) {
        return false;
    }

From here you get the events from the activity and can do whatever you want.