Cleaned up LunarLander sample

Change-Id: If2cc44c8312cebce170d07c34c64ea2ce1e5b7ab
This commit is contained in:
Christian Mehlmauer
2010-07-02 16:20:49 +02:00
parent a96f73a683
commit 3eda8fc385
2 changed files with 17 additions and 20 deletions

View File

@@ -21,7 +21,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.TextView;
import com.example.android.lunarlander.LunarView.LunarThread;
@@ -58,7 +57,7 @@ public class LunarLander extends Activity {
/**
* Invoked during init to give the Activity a chance to set up its Menu.
*
*
* @param menu the Menu to which entries may be added
* @return true
*/
@@ -79,7 +78,7 @@ public class LunarLander extends Activity {
/**
* Invoked when the user selects an item from the Menu.
*
*
* @param item the Menu entry which was selected
* @return true if the Menu item was legit (and we consumed it), false
* otherwise
@@ -116,7 +115,7 @@ public class LunarLander extends Activity {
/**
* Invoked when the Activity is created.
*
*
* @param savedInstanceState a Bundle containing state saved from a previous
* execution, or null if this is a new execution
*/
@@ -157,7 +156,7 @@ public class LunarLander extends Activity {
/**
* Notification that something is about to happen, to give the Activity a
* chance to save state.
*
*
* @param outState a Bundle into which this Activity should save its state
*/
@Override

View File

@@ -37,7 +37,7 @@ import android.widget.TextView;
/**
* View that draws, takes keystrokes, etc. for a simple LunarLander game.
*
*
* Has a mode which RUNNING, PAUSED, etc. Has a x, y, dx, dy, ... capturing the
* current ship physics. All x/y etc. are measured with (0,0) at the lower left.
* updatePhysics() advances the physics based on realtime. draw() renders the
@@ -112,14 +112,14 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Current height of the surface/canvas.
*
*
* @see #setSurfaceSize
*/
private int mCanvasHeight = 1;
/**
* Current width of the surface/canvas.
*
*
* @see #setSurfaceSize
*/
private int mCanvasWidth = 1;
@@ -321,7 +321,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
* Restores game state from the indicated Bundle. Typically called when
* the Activity is being restored after having been previously
* destroyed.
*
*
* @param savedState Bundle containing the game state
*/
public synchronized void restoreState(Bundle savedState) {
@@ -372,7 +372,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Dump game state to the provided Bundle. Typically called when the
* Activity is being suspended.
*
*
* @return Bundle with this view's state
*/
public Bundle saveState(Bundle map) {
@@ -400,7 +400,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Sets the current difficulty.
*
*
* @param difficulty
*/
public void setDifficulty(int difficulty) {
@@ -423,7 +423,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
* Passing true allows the thread to run; passing false will shut it
* down if it's already running. Calling start() after this was most
* recently called with false will result in an immediate shutdown.
*
*
* @param b true to run, false to shut down
*/
public void setRunning(boolean b) {
@@ -433,7 +433,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Sets the game mode. That is, whether we are running, paused, in the
* failure state, in the victory state, etc.
*
*
* @see #setState(int, CharSequence)
* @param mode one of the STATE_* constants
*/
@@ -446,7 +446,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Sets the game mode. That is, whether we are running, paused, in the
* failure state, in the victory state, etc.
*
*
* @param mode one of the STATE_* constants
* @param message string to add to screen or null
*/
@@ -509,7 +509,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
mCanvasHeight = height;
// don't forget to resize the background image
mBackgroundImage = mBackgroundImage.createScaledBitmap(
mBackgroundImage = Bitmap.createScaledBitmap(
mBackgroundImage, width, height, true);
}
}
@@ -527,7 +527,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Handles a key-down event.
*
*
* @param keyCode the key that was pressed
* @param msg the original event object
* @return true
@@ -539,8 +539,6 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) okStart = true;
if (keyCode == KeyEvent.KEYCODE_S) okStart = true;
boolean center = (keyCode == KeyEvent.KEYCODE_DPAD_UP);
if (okStart
&& (mMode == STATE_READY || mMode == STATE_LOSE || mMode == STATE_WIN)) {
// ready-to-start -> start
@@ -579,7 +577,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Handles a key-up event.
*
*
* @param keyCode the key that was pressed
* @param msg the original event object
* @return true if the key was handled and consumed, or else false
@@ -807,7 +805,7 @@ class LunarView extends SurfaceView implements SurfaceHolder.Callback {
/**
* Fetches the animation thread corresponding to this LunarView.
*
*
* @return the animation thread
*/
public LunarThread getThread() {