Learning Java by Building Android Games by John Horton

Learning Java by Building Android Games by John Horton

Author:John Horton
Language: eng
Format: epub, pdf
Publisher: Packt Publishing


Coding onTouchEvent

Next on our to-do list is onTouchEvent which is called by Android every time the player interacts with the screen. We will add more code here as we progress. For now, add the following code which, if mPaused is true, sets mPaused to false and calls the newGame method.

@Override public boolean onTouchEvent(MotionEvent motionEvent) { switch (motionEvent.getAction() &MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: if (mPaused) { mPaused = false; newGame(); // Don't want to process snake // direction for this tap return true; } // Let the Snake class handle the input break; default: break; } return true; }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.