javaandroid打地⿏_Android打地⿏游戏源代码[android]代码库ample.game.gamehit;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog.Builder;
t.Context;
t.DialogInterface;
dia.AudioManager;
dia.MediaPlayer;java手机游戏下载
dia.SoundPool;
import android.os.Bundle;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
ample.game.gamehitmon.Const;
ample.game.gamehit.util.MUtils;
@SuppressLint("ResourceAsColor")
public class MainActivity extends Activity {
private MediaPlayer mBgMediaPlayer;
crmprivate boolean isMusic = true;
private Context mContext;
private static SoundPool mSoundPool = new SoundPool(1,
AudioManager.STREAM_MUSIC, 0);
/** 0:打;1:打中;2死机 */
private int[] soundIds = { -1, -1, -1, -1, -1 };
public boolean isPause;
public GameView gameView;
@Override
public void onCreate(Bundle savedInstanceState) {
// setContentView(R.layout.activity_main);
requestWindowFeature(Window.FEATURE_NO_TITLE);// ⽆标题
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);// 全屏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // 应⽤运⾏时,保持屏幕⾼亮,不锁屏init();
gameView = new GameView(MainActivity.this);
setContentView(gameView);
// playBackgroundVoide();
}
/**
*
*/
private void init() {
mContext = MainActivity.this;
initGameMode();
mBgMediaPlayer = ate(mContext, Const.voiceBackground);
mBgMediaPlayer.setLooping(true);// 循环
soundIds[Const.voiceShoot] = mSoundPool.load(mContext, R.raw.shoot, 1);
soundIds[Const.voiceHit] = mSoundPool.load(mContext, R.raw.hit, 1);
soundIds[Const.voiceNo] = mSoundPool.load(mContext, , 1);
soundIds[Const.voiceNextlevel] = mSoundPool.load(mContext,
level, 1);
soundIds[Const.voiceGameover] = mSoundPool.load(mContext,
R.raw.gameover, 1);
adMethod();
}
/**
*
*/
private void adMethod() {
MUtils.showRight();
MUtils.showBtoom();
marquee boost 偏大
crunchbase是什么}
/*
* (non-Javadoc)
*
* @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (KeyCode()) {
case KeyEvent.KEYCODE_BACK:
finish();
return true;
}
// KeyDown(keyCode, event)
return false;
}
/**
* @return
*/
private boolean isGotomenu() {
isPause = true;
boolean flag = false;
Builder gotoMenu = new Builder(mContext);
TextView textView = new TextView(mContext);
textView.setText("要返回菜单吗?");
textView.setTextSize(24);
textView.setTextColor(getResources().lor.fontColor)); textView.setGravity(Gravity.CENTER);
textView.setBackgroundColor(getResources().getColor(
lor.darker_gray));
gotoMenu.setView(textView);
gotoMenu.setPositiveButton("是", new DialogInterface.OnClickListener() { @Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
gotoMenu.setNegativeButton("否", null);
gotoMenu.show();
return flag;
}
public void nextLevel() {
playVoice(Const.voiceNextlevel);
TextView textView = new TextView(mContext);
textView.setText("成功过关!你真棒!");
textView.setTextSize(24);
textView.setTextColor(getResources().lor.fontColor)); textView.setGravity(Gravity.CENTER);
textView.setBackgroundColor(getResources().getColor(
lor.darker_gray));
Builder nextLevel = new Builder(mContext);
nextLevel.setView(textView);
nextLevel.setPositiveButton("下⼀关",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
gameView.startGame();
}
});
nextLevel.setNegativeButton("返回菜单",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
nextLevel.setCancelable(false);
nextLevel.show();
}
public void gameOver() {
playVoice(Const.voiceGameover);
ImageView imgView = new ImageView(mContext);
imgView.setBackgroundColor(getResources().getColor(
lor.darker_gray));
imgView.setBackgroundResource(R.drawable.gameover);
Builder gameOver = new Builder(mContext);
gameOver.setView(imgView);
gameOver.setPositiveButton("重新挑战",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
gameView.initGameInfo();
}
});
gameOver.setNegativeButton("返回菜单",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
gameOver.setCancelable(false);
gameOver.show();
parse()}
@SuppressLint("ResourceAsColor")
public void showTimerGrade(int grade, int killnum) {
playVoice(Const.voiceNextlevel);
Builder timerGrade = new Builder(mContext);
java技术面试完了复试TextView textView = new TextView(mContext);
textView.setText("本次" + Const.timeNum + "秒计时\r\n击中:" + killnum + "个\r\n得分:" + grade + "分");
textView.setTextColor(getResources().lor.fontColor));
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论