i just changed the
Using java Syntax Highlighting
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent msg) {
- if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
lines to
Using java Syntax Highlighting
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_DOWN)
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
But i still wanted to control the snake from the on-screen keyboard, so i moved
Using java Syntax Highlighting
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent msg) {
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
to when the motionevent ended,
so i still could use the keyCodes to control the snake. but i get errors:
override cannot be resolved to a type
This method must return a result of type boolean (onTouchEvent(MotionEvent event)
this got confusing, sry, the lines i tried to change below.
Using java Syntax Highlighting
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- if (mMode == READY | mMode == LOSE) {
- }
- }
- }
- /*
- * At the beginning of the game, or the end of a previous one,
- * we should start a new game.
- */
- @override
- public boolean onKeyDown(int keyCode, KeyEvent msg) {
- initNewGame();
- setMode(RUNNING);
- update();
- return (true);
- if (mMode == PAUSE) {
- /*
- * If the game is merely paused, we should just continue where
- * we left off.
- */
- setMode(RUNNING);
- update();
- return (true);
- }
- if (mDirection != SOUTH) {
- mNextDirection = NORTH;
- }
- return (true);
- if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
- if (mDirection != NORTH) {
- mNextDirection = SOUTH;
- }
- return (true);
- }
- if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
- if (mDirection != EAST) {
- mNextDirection = WEST;
- }
- return (true);
- }
- if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
- if (mDirection != WEST) {
- mNextDirection = EAST;
- }
- return (true);
- }
- return super.onKeyDown(keyCode, msg);
- }
Parsed in 0.040 seconds, using GeSHi 1.0.8.4



