FileDocCategorySizeDatePackage
LunarLander.javaAPI DocGoogle Android v1.5 Example3769Sun Nov 11 13:01:04 GMT 2007com.google.android.lunarlander

LunarLander

public class LunarLander extends android.app.Activity
This is a simple LunarLander activity that houses a single LunarView. It demonstrates...
  • animating by calling invalidate() from draw()
  • loading and drawing resources
  • handling onPause() in an animation

Fields Summary
private LunarView
mLunarView
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        // Turn off the title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // Make our view
        setContentView(R.layout.lunar_layout);
        mLunarView = (LunarView) findViewById(R.id.lunar);
        
        // Tell the view about the text view
        mLunarView.setTextView((TextView)findViewById(R.id.text));
        
        if (icicle == null) {
            // We were just launched -- set up a new game
            mLunarView.setMode(LunarView.READY);
        } else {
            // We are being restored
            Bundle map = icicle.getBundle("lunar-view");
            if (map != null) {
                mLunarView.restoreState(map);
            } else {
                mLunarView.setMode(LunarView.READY);
            }
        }
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        super.onCreateOptionsMenu(menu);

        menu.add(0, 0, R.string.menu_start, new Runnable() {
            public void run() {
                mLunarView.doStart();
            }
        });

        menu.add(0, 0, R.string.menu_stop, new Runnable() {
            public void run() {
                mLunarView.setMode(LunarView.LOSE, LunarLander.this.
                        getText(R.string.message_stopped));
            }
        });


        menu.add(0, 0, R.string.menu_pause, new Runnable() {
            public void run() {
                mLunarView.doPause();
            }
        });

        menu.add(0, 0, R.string.menu_resume, new Runnable() {
            public void run() {
                mLunarView.doResume();
            }
        });
        
        menu.addSeparator(0, 0);

        menu.add(0, 0, R.string.menu_easy, new Runnable() {
            public void run() {
                mLunarView.setDifficulty(LunarView.EASY);
            }
        });

        menu.add(0, 0, R.string.menu_medium, new Runnable() {
            public void run() {
                mLunarView.setDifficulty(LunarView.MEDIUM);
            }
        });

        menu.add(0, 0, R.string.menu_hard, new Runnable() {
            public void run() {
                mLunarView.setDifficulty(LunarView.HARD);
            }
        });
        
        return true;
    
protected voidonFreeze(android.os.Bundle outState)

        // Remember game state
        outState.putBundle("lunar-view", mLunarView.saveState());
    
protected voidonPause()

        super.onPause();
        // Pause the came when our activity pauses
        mLunarView.doPause();