📄 lunarlander.java
字号:
/* * Copyright (C) 2007 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.google.android.lunarlander;import android.app.Activity;import android.os.Bundle;import android.view.Menu;import android.view.Window;import android.widget.TextView;/** * This is a simple LunarLander activity * that houses a single LunarView. It demonstrates... * <ul> * <li>animating by calling invalidate() from draw() * <li>loading and drawing resources * <li>handling onPause() in an animation * </ul> */public class LunarLander extends Activity { private LunarView mLunarView; @Override protected void onCreate(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); } } } @Override protected void onPause() { super.onPause(); // Pause the came when our activity pauses mLunarView.doPause(); } @Override protected void onFreeze(Bundle outState) { // Remember game state outState.putBundle("lunar-view", mLunarView.saveState()); } @Override public boolean onCreateOptionsMenu(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; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -