AI 144539: am: CL 144533 Reformat JetBoy samples to match code style.
Original author: xav Merged from: //branches/cupcake/... Automated import of CL 144539
This commit is contained in:
committed by
The Android Open Source Project
parent
62464e0187
commit
46132107e6
@@ -34,4 +34,5 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
<uses-sdk android:minSdkVersion="3"></uses-sdk>
|
||||||
</manifest>
|
</manifest>
|
||||||
11
samples/JetBoy/default.properties
Normal file
11
samples/JetBoy/default.properties
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system use,
|
||||||
|
# "build.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
|
||||||
|
# Project target.
|
||||||
|
target=android-3
|
||||||
@@ -15,17 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME: review and cleanup
|
// FIXME: review and cleanup
|
||||||
|
|
||||||
package com.example.android.jetboy;
|
package com.example.android.jetboy;
|
||||||
|
|
||||||
public class Asteroid {
|
public class Asteroid {
|
||||||
|
|
||||||
public int mAniIndex = 0;
|
public int mAniIndex = 0;
|
||||||
public int mDrawY = 0;
|
public int mDrawY = 0;
|
||||||
public int mDrawX = 0;
|
public int mDrawX = 0;
|
||||||
|
|
||||||
public boolean mExploding = false;
|
public boolean mExploding = false;
|
||||||
public boolean mMissed = false;
|
public boolean mMissed = false;
|
||||||
|
|
||||||
public long mStartTime = 0;
|
public long mStartTime = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME: review and cleanup
|
// FIXME: review and cleanup
|
||||||
|
|
||||||
package com.example.android.jetboy;
|
package com.example.android.jetboy;
|
||||||
|
|
||||||
public class Explosion {
|
public class Explosion {
|
||||||
|
|
||||||
public int mAniIndex = 0;
|
public int mAniIndex = 0;
|
||||||
public int mDrawY = 0;
|
public int mDrawY = 0;
|
||||||
public int mDrawX = 0;
|
public int mDrawX = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,41 +19,39 @@
|
|||||||
package com.example.android.jetboy;
|
package com.example.android.jetboy;
|
||||||
|
|
||||||
import com.example.android.jetboy.JetBoyView.JetBoyThread;
|
import com.example.android.jetboy.JetBoyView.JetBoyThread;
|
||||||
import com.example.android.jetboy.JetBoyView;
|
|
||||||
import com.example.android.jetboy.R;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class JetBoy extends Activity implements View.OnClickListener{
|
public class JetBoy extends Activity implements View.OnClickListener {
|
||||||
|
|
||||||
/** A handle to the thread that's actually running the animation. */
|
/** A handle to the thread that's actually running the animation. */
|
||||||
private JetBoyThread mJetBoyThread;
|
private JetBoyThread mJetBoyThread;
|
||||||
|
|
||||||
/** A handle to the View in which the game is running. */
|
/** A handle to the View in which the game is running. */
|
||||||
private JetBoyView mJetBoyView;
|
private JetBoyView mJetBoyView;
|
||||||
|
|
||||||
//the play start button
|
// the play start button
|
||||||
private Button mButton;
|
private Button mButton;
|
||||||
|
|
||||||
//used to hit retry
|
// used to hit retry
|
||||||
private Button mButtonRetry;
|
private Button mButtonRetry;
|
||||||
|
|
||||||
//the window for instructions and such
|
// the window for instructions and such
|
||||||
private TextView mTextView;
|
private TextView mTextView;
|
||||||
|
|
||||||
//game window timer
|
// game window timer
|
||||||
private TextView mTimerView;
|
private TextView mTimerView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required method from parent class
|
* Required method from parent class
|
||||||
|
*
|
||||||
* @param savedInstanceState - The previous instance of this app
|
* @param savedInstanceState - The previous instance of this app
|
||||||
*/
|
*/
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -66,26 +64,25 @@ public class JetBoy extends Activity implements View.OnClickListener{
|
|||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
// get handles to the JetView from XML and the JET thread.
|
// get handles to the JetView from XML and the JET thread.
|
||||||
mJetBoyView = (JetBoyView) findViewById(R.id.JetBoyView);
|
mJetBoyView = (JetBoyView)findViewById(R.id.JetBoyView);
|
||||||
mJetBoyThread = mJetBoyView.getThread();
|
mJetBoyThread = mJetBoyView.getThread();
|
||||||
|
|
||||||
//look up the happy shiny button
|
// look up the happy shiny button
|
||||||
mButton = (Button)findViewById(R.id.Button01);
|
mButton = (Button)findViewById(R.id.Button01);
|
||||||
mButton.setOnClickListener(this);
|
mButton.setOnClickListener(this);
|
||||||
|
|
||||||
mButtonRetry = (Button)findViewById(R.id.Button02);
|
mButtonRetry = (Button)findViewById(R.id.Button02);
|
||||||
mButtonRetry.setOnClickListener(this);
|
mButtonRetry.setOnClickListener(this);
|
||||||
|
|
||||||
//set up handles for instruction text and game timer text
|
// set up handles for instruction text and game timer text
|
||||||
mTextView = (TextView) findViewById(R.id.text);
|
mTextView = (TextView)findViewById(R.id.text);
|
||||||
mTimerView = (TextView) findViewById(R.id.timer);
|
mTimerView = (TextView)findViewById(R.id.timer);
|
||||||
|
|
||||||
mJetBoyView.setTimerView(mTimerView);
|
mJetBoyView.setTimerView(mTimerView);
|
||||||
|
|
||||||
mJetBoyView.SetButtonView(mButtonRetry);
|
mJetBoyView.SetButtonView(mButtonRetry);
|
||||||
|
|
||||||
mJetBoyView.SetTextView(mTextView);
|
mJetBoyView.SetTextView(mTextView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,67 +92,64 @@ public class JetBoy extends Activity implements View.OnClickListener{
|
|||||||
*/
|
*/
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
//this is the first screen
|
// this is the first screen
|
||||||
if (mJetBoyThread.getGameState()==mJetBoyThread.STATE_START){
|
if (mJetBoyThread.getGameState() == mJetBoyThread.STATE_START) {
|
||||||
mButton.setText("PLAY!");
|
mButton.setText("PLAY!");
|
||||||
mTextView.setVisibility(View.VISIBLE);
|
mTextView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mTextView.setText(R.string.helpText);
|
mTextView.setText(R.string.helpText);
|
||||||
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
|
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
|
||||||
|
|
||||||
}
|
}
|
||||||
//we have entered game play, now we about to start running
|
// we have entered game play, now we about to start running
|
||||||
else if (mJetBoyThread.getGameState()==mJetBoyThread.STATE_PLAY){
|
else if (mJetBoyThread.getGameState() == mJetBoyThread.STATE_PLAY) {
|
||||||
mButton.setVisibility(View.INVISIBLE);
|
mButton.setVisibility(View.INVISIBLE);
|
||||||
mTextView.setVisibility(View.INVISIBLE);
|
mTextView.setVisibility(View.INVISIBLE);
|
||||||
mTimerView.setVisibility(View.VISIBLE);
|
mTimerView.setVisibility(View.VISIBLE);
|
||||||
mJetBoyThread.setGameState(JetBoyThread.STATE_RUNNING);
|
mJetBoyThread.setGameState(JetBoyThread.STATE_RUNNING);
|
||||||
|
|
||||||
}
|
}
|
||||||
//this is a retry button
|
// this is a retry button
|
||||||
else if (mButtonRetry.equals(v) ){
|
else if (mButtonRetry.equals(v)) {
|
||||||
|
|
||||||
mTextView.setText(R.string.helpText);
|
mTextView.setText(R.string.helpText);
|
||||||
|
|
||||||
mButton.setText("PLAY!");
|
mButton.setText("PLAY!");
|
||||||
mButtonRetry.setVisibility(View.INVISIBLE);
|
mButtonRetry.setVisibility(View.INVISIBLE);
|
||||||
//mButtonRestart.setVisibility(View.INVISIBLE);
|
// mButtonRestart.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
mTextView.setVisibility(View.VISIBLE);
|
mTextView.setVisibility(View.VISIBLE);
|
||||||
mButton.setText("PLAY!");
|
mButton.setText("PLAY!");
|
||||||
mButton.setVisibility(View.VISIBLE);
|
mButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
|
mJetBoyThread.setGameState(JetBoyThread.STATE_PLAY);
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.d("JB VIEW", "unknown click " + v.getId());
|
Log.d("JB VIEW", "unknown click " + v.getId());
|
||||||
|
|
||||||
Log.d("JB VIEW", "state is " + mJetBoyThread.mState);
|
Log.d("JB VIEW", "state is " + mJetBoyThread.mState);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard override to get key-press events.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent msg) {
|
||||||
|
|
||||||
/**
|
if (keyCode == 4)
|
||||||
* Standard override to get key-press events.
|
super.onKeyDown(keyCode, msg);
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent msg) {
|
|
||||||
|
|
||||||
if (keyCode == 4) super.onKeyDown(keyCode,msg);
|
return mJetBoyThread.doKeyDown(keyCode, msg);
|
||||||
|
}
|
||||||
|
|
||||||
return mJetBoyThread.doKeyDown(keyCode, msg);
|
/**
|
||||||
}
|
* Standard override for key-up. We actually care about these, so we can
|
||||||
|
* turn off the engine or stop rotating.
|
||||||
/**
|
*/
|
||||||
* Standard override for key-up. We actually care about these, so we can
|
@Override
|
||||||
* turn off the engine or stop rotating.
|
public boolean onKeyUp(int keyCode, KeyEvent msg) {
|
||||||
*/
|
return mJetBoyThread.doKeyUp(keyCode, msg);
|
||||||
@Override
|
}
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent msg) {
|
}
|
||||||
return mJetBoyThread.doKeyUp(keyCode, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user