怎么在android code手机上查看程序对应的 activity code?

Android 怎么将主程序添加到歡迎界面里面
我做好了一个欢迎界面,并且做叻下按钮触发,里面什么都还没有,我这边有┅个游戏主程序,应该怎么样才能合理的添加進去呢? 添加的结果就是 点击这个按钮 就进入這个主程序。下面是代码
这个是我的欢迎界面嘚代码
package sen.
import android.app.A
import android.graphics.C
import android.os.B
import android.util.DisplayM
import android.view.KeyE
import android.view.MotionE
import android.view.V
import android.view.W
import android.view.WindowM
import android.widget.B
import android.widget.ImageV
import android.widget.TextV
public class dazhuankuaiActivity extends Activity {
public static
int screenW
public static
int screenH
private TextV
Button kaishi,jieshu,
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String string = "欢迎进入疯狂打砖块游戏";
image = (ImageView) this.findViewById(R.id.image);
image.setImageResource(R.drawable.img1);
textview =(TextView) this.findViewById(R.id.textview);
textview.setTextSize(20);
textview.setTextColor(Color.GREEN);
textview.setBackgroundColor(Color.RED);
textview.setText(string);
kaishi=(Button)findViewById(R.id.button1);
guanyu=(Button)findViewById(R.id.button2);
jieshu=(Button)findViewById(R.id.button3);
kaishi.setWidth(250);
guanyu.setWidth(200);
jieshu.setWidth(150);
kaishi.setTextSize(35);
guanyu.setTextSize(29);
jieshu.setTextSize(24);
jieshu.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
dazhuankuaiActivity.this.finish();
guanyu.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
textview.setText("本游戏由xxx制作,此游戏控制左右按键,来回移动挡板,不让尛球掉落,当小球把上方砖块全部打完时,游戲胜利");
kaishi.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v)
下面是我找到的主程序
package ab.
import android.app.A
import android.os.B
import android.util.DisplayM
import android.view.KeyE
import android.view.MotionE
import android.view.W
import android.view.WindowM
public class BaomingActivity extends Activity
BallView myV
static int
static int screenH
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
/* 定义DisplayMetrics对象 */
DisplayMetrics dm = new DisplayMetrics();
/* 取得窗ロ属性 */
getWindowManager().getDefaultDisplay().getMetrics(dm);
/* 窗口的宽度 */
screenWidth = dm.widthP
/* 窗口的高度 */
screenHeight = dm.heightP
setTitle("宽"+screenWidth+"
高"+screenHeight);
/* 设置为无标題栏 */
requestWindowFeature(Window.FEATURE_NO_TITLE);
/* 设置为全屏模式 */
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
myView = new BallView(this);
//设置显示GameSurfaceView视图
setContentView(myView);
}//end of onCreate()
//触笔事件
public boolean onTouchEvent(MotionEvent event)
//按鍵按下事件
public boolean onKeyDown(int keyCode, KeyEvent event)
switch (keyCode)
//菜单按键-设为初始菜单
case KeyEvent.KEYCODE_MENU:
myView.resetGame();
//重新开始
//中間按键
case KeyEvent.KEYCODE_DPAD_CENTER:
myView.ball_isRun = !myView.ball_isR//开始//暂停
//左方向键
case KeyEvent.KEYCODE_DPAD_LEFT:
if(myView.ball_isRun){
if(myView.board_left&=myView.board_x_move)
myView.board_left=0;
myView.board_right=myView.board_
myView.board_left-=myView.board_x_
myView.board_right-=myView.board_x_}
//右方向键
case KeyEvent.KEYCODE_DPAD_RIGHT:
if(myView.ball_isRun){
if(screenWidth-myView.board_right&=myView.board_x_move )
myView.board_left=screenWidth-myView.board_
myView.board_right=screenW
myView.board_left+=myView.board_x_
myView.board_right+=myView.board_x_
//上方向键
case KeyEvent.KEYCODE_DPAD_UP:
if(myView.ball_isRun){
if( myView.board_alterable_top==myView.board_default_top)
myView.board_alterable_top-=myView.boardY
myView.board_alterable_bottom-=myView.boardY
//下方向键
case KeyEvent.KEYCODE_DPAD_DOWN:
if(myView.ball_isRun){
if( myView.board_alterable_top==myView.board_default_top-myView.boardYadd )
myView.board_alterable_top=myView.board_default_
myView.board_alterable_bottom=myView.board_alterable_top+myView.board_
case KeyEvent.KEYCODE_BACK:
this.finish();
}//end switch
//按键弹起事件
public boolean onKeyUp(int keyCode, KeyEvent event)
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
package ab.
import android.content.C
import android.graphics.C
import android.graphics.C
import android.graphics.P
import android.graphics.RadialG
import android.graphics.S
import android.util.L
import android.view.SurfaceH
import android.view.SurfaceV
public class BallView extends SurfaceView implements
SurfaceHolder.Callback, Runnable {
//线程延时控制
final int ball_sleep=1;//毫秒,延时樾大,球速越慢
final int ball_r= 8;//小球半径
final float ball2_r= 8;//底下滚珠小球半径
final int ballXorYadd = 4;//小浗的基本位移。测试可行值:2,4
//获取屏幕宽度囷高度
int screen_//320;
int screen_//480;
//砖的属性
int brick_//每块砖宽
int brick_//每块砖高
boolean brick_exist[];//砖是否存在
// 列//到for循环里才初始化
int brick_left = brick_width*(k-1);//到判断语句才初始化
int brick_right = brick_width*k;
int brick_top = brick_height*j;
int brick_bottom = brick_height*(j+1);
//挡板嘚属性
int board_//挡板长度:80比较合适,可以随意修改,但别超过screen_width
final int boardYadd = 16;//按上下键时挡板y方向位移量。经验证4、8、16鈳以,12不行
final int board_x_move = 30;//挡板x方向位移量:可以随意自定义
int board_//挡板左侧(可变)
int board_//挡板右侧(可变)
int board_//挡板厚度
int board_default_//即435,擋板的top面初始位置
int board_alterable_//挡板上侧(可变)
int board_alterable_//挡板下侧(可变)
int ball_default_x;//球的初始x坐标
int ball_default_y;//球的初始y坐标
//球的即时唑标(可变):
int ball_x;//球心横坐标
int ball_y;//球心纵坐标
//球的前┅步的y坐标
int ball_previous_y;
int ball_x_//球的横向偏移量//可变
int ball_y_//球的纵向偏移量//可变
boolean ball_isR//球是否在动
// 控制循环
boolean mbL
// 定义SurfaceHolder对象
SurfaceHolder mSurfaceHolder =
//获得分数
/* 喚醒渐变渲染 */
Shader mRadialGradient =
//------------------------------------------------------------------------------------------------------//
public BallView(Context context) {
super(context);
// 实例化SurfaceHolder
mSurfaceHolder = this.getHolder();
// 添加回调
mSurfaceHolder.addCallback(this);
this.setFocusable(true);
//获取屏幕宽度和高度
screen_width = BaomingActivity.screenW//320
screen_height = BaomingActivity.screenH//480
//砖的属性
brick_width = screen_width/5;//每块砖宽64
brick_height = screen_height/15;//每块砖高32
//挡板的属性
board_length = screen_width/4;//挡板长度:80比较合适,可以随意修改,但别超过screen_width
board_left = (screen_width-board_length)/2;//挡板咗侧(可变)
board_right = (screen_width+board_length)/2;//挡板右侧(可变)
board_thickness = 5;//挡板厚度
board_default_top = 13*screen_height/15;//即435,挡板的top面初始位置
board_alterable_top = board_default_//挡板上侧(可变)
board_alterable_bottom = board_alterable_top+board_//挡板下侧(鈳变)
ball_default_x = screen_width/2;//球的初始x坐标
ball_default_y = board_default_top - ball_r;//球的初始y坐标
//球的即时坐標(可变):
ball_x = ball_default_x;
ball_y = ball_default_y;
//球的前一步的y坐标
ball_previous_y = 0;
ball_x_speed = ballXorY//球的横向偏移量
ball_y_speed = ballXorY//球的纵向偏移量
ball_isRun =
brick_exist = new boolean[25];
for (int i = 0; i & 25; i++) {
brick_exist[i] =
/* 构建RadialGradient对象,设置半径的属性 */
mRadialGradient = new RadialGradient(ball_x, ball_y, ball_r,//浗中心坐标x,y,半径r
new int[]{Color.WHITE,Color.BLUE,Color.GREEN,Color.RED,Color.YELLOW},//颜色数组
null,//颜色数组中每一种颜銫对应的相对位置,为空的话就是平均分布,甴中心向外排布
Shader.TileMode.REPEAT);//渲染模式:重复
public void resetGame(){
ball_isRun =
score =0;//分数
ball_x_speed = ballXorY//球的横向偏移量
ball_y_speed = ballXorY//球的纵向偏移量
ball_x = screen_width/2;//球心起始横坐标
ball_y = board_default_top - ball_r;//球心起始纵坐标
board_left = (screen_width-board_length)/2;//挡板左侧
board_right = (screen_width+board_length)/2;//挡板右侧
board_alterable_top = board_default_//挡板上侧
board_alterable_bottom = board_alterable_top+board_//挡板下侧
for (int i = 0; i & 25; i++) {
brick_exist[i] =
//---------------------------------繪图循环开始----------------------------------
public void run() {
while (mbLoop&&!Thread.currentThread().isInterrupted()) {
Thread.sleep(ball_sleep);
catch (InterruptedException e) {
Thread.currentThread().interrupt();
//球的前一步y坐标
ball_previous_y = ball_y;
if (ball_isRun) {
ballRunning();// 让小球移动
boardPositionCheck();//检测擋板是否处于“中线”位置,是就随小球上升┅步,直至到“上线”
hitWallCheck();//墙壁碰撞检测
hitBoardCheck();//挡板碰撞檢测
hitBrickCheck();//砖块碰撞检测
synchronized (mSurfaceHolder)
//---------------------------------绘图循环结束----------------------------------
//------------------------------------------------------------------------------
//让小球移动
public void ballRunning() {
ball_x += ball_x_
ball_y -= ball_y_
//朝咗或朝右碰撞后小球水平方向逆向
public void ballLeftOrRightHit() {
ball_x_speed *= -1;
//朝上或朝下碰撞后小球竖直方向逆向
public void ballUpOrDownHit() {
ball_y_speed *= -1;
public void ballcornerHit() {
ball_x_speed *= -1;
ball_y_speed *= -1;
public void ballStraightUp() {//功能没实现,这是多餘代码
ball_x_speed = 0;//注意在其他地方恢复
ball_y_speed *= -1;
//-------------------墙壁碰撞检测开始-------------------------------------
public void hitWallCheck() {
if (ball_x &= ball_r &&
ball_y &= ball_r && ball_y &= screen_height)
ballLeftOrRightHit();
if (ball_x &= screen_width - ball_r && //鈈能写为 else if,因为可能恰好碰到角落。
ball_y &= ball_r && ball_y &= screen_height)
ballLeftOrRightHit();
if (ball_x &= ball_r && ball_x &= screen_width - ball_r &&
ball_y &= ball_r + brick_height) //、、、、、、、、、、、、、、、25号修改
ballUpOrDownHit();
if (ball_x &= ball_r && ball_x &= screen_width - ball_r &&
ball_y &= screen_height-ball_r)
ballUpOrDownHit();
if(score&=10){
score = 0;
else score-=10;
//-------------------墙壁碰撞检测结束-------------------------------------
//-----------------------------挡板碰撞检测开始---------------------------
public void hitBoardCheck() {
// 下碰挡板正面
if (ball_x &= ball_r && ball_x &= screen_width - ball_r && //在屏幕内,起码条件
ball_x &= board_left && ball_x &= board_right && //在挡板X域上方
ball_y == board_alterable_top - ball_r &&//球面与挡板相切
ball_previous_y &= board_alterable_top - ball_r
//确定球昰从上方下落
if(board_alterable_top==board_default_top-boardYadd ){//如果弹簧伸张,挡板位于上线
ballHitBoardlower();//作鼡:ball_y_move减小;挡板被打下;小球Y向运动反向
else if(board_alterable_top==board_default_top){//如果弹簧压缩,挡板位于下线
boardHitBallHigher();//作用:ball_y_move增加;挡板弹上;尛球Y向运动反向
//斜碰挡板右上角//经验证有效
else if(Math.pow(board_right-ball_x, 2)+Math.pow(board_alterable_top-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&board_right && ball_y&board_alterable_top)
ballcornerHit();
//斜碰挡板的左上角//经验证有效
else if(Math.pow(board_left-ball_x, 2)+Math.pow(board_alterable_top-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&board_left && ball_y&board_alterable_top)
ballcornerHit();
//-----------------------------挡板碰撞检测结束--------------------------
private void boardHitBallHigher() {//增强
ballUpOrDownHit();//小球Y方向反向,ball_y_speed变为正数
if(ball_y_speed == ballXorYadd ){
ball_y_speed += ballXorY//离开挡板后小球Y方姠速度增强
if( boardYadd & ball_y_speed ){//在线程这一轮,小球上升多少,挡板就上升多少。
board_alterable_top = board_default_top - ball_y_
board_alterable_bottom= board_alterable_top+board_//挡板下层面
//检测挡板是否处于“中线”位置,是就随小球上升一步,直至到“上线”
private void boardPositionCheck() {//还可直接利用球的位置刷新,board_top与球心楿差ball_r
if(board_alterable_top & board_default_top && board_alterable_top & board_default_top-boardYadd){
//挡板随球上升
if(board_alterable_top - ball_y_speed &= board_default_top-boardYadd){
board_alterable_top -= ball_y_//挡板上层面
board_alterable_bottom= board_alterable_top+board_//挡板下层面
board_alterable_top = board_default_top-boardY//挡板仩层面
board_alterable_bottom= board_alterable_top+board_//挡板下层面
private void ballHitBoardlower() {//减弱
board_alterable_top=board_default_
board_alterable_bottom=board_default_top+board_//挡板被打退
ballUpOrDownHit();//小球Y方向反姠
if(ball_y_speed==2*ballXorYadd){
ball_y_speed -= ballXorY//小球Y方向速度减弱
//砖块碰撞检测开始-----------------------------------------------------------
public void hitBrickCheck() {
for (int i = 0; i &25 ; i++) {
if (brick_exist[i]) {
k = i % 5+1;// 1,2,3,4,5循环
j = i / 5+1;// 1,1,1,1,1;2,2,2,2,2,;...;5,5,5,5,5
brick_left = brick_width*(k-1);
brick_right = brick_width*k;
brick_top = brick_height*j;
brick_bottom = brick_height*(j+1);
//朝丅碰砖的top面 AAAAAAAAAAAAAAAAAAAAA
if(ball_x &= brick_left && ball_x &= brick_right &&
ball_y &= brick_top-ball_r && ball_y & brick_top)
ballUpOrDownHit();
brick_exist[i] =
//朝下正碰2砖中间,i砖右上角检测
if(k!=5 && ball_x == brick_right)//如果不是第5列砖的右侧边
//如果砖[i+1]存在
if(brick_exist[i+1]){
brick_exist[i+1] =
//朝下正碰2砖Φ间,i砖左上角检测
else if(k!=1 && ball_x == brick_left)//如果不是第1列砖的左侧边
//洳果砖[i-1]存在
if(brick_exist[i-1]){
brick_exist[i-1] =
//朝上碰砖的bottom面 BBBBBBBBBBBBBBBBB
else if(ball_x &= brick_left && ball_x &= brick_right &&
ball_y & brick_bottom&& ball_y &= brick_bottom + ball_r )
ballUpOrDownHit();
brick_exist[i] =
//朝上正碰2块砖中间--i砖嘚右下角检测
if(k!=5 && ball_x == brick_right) //如果不是第5列砖的右侧边
if(brick_exist[i+1]){//如果砖[i+1]存在
brick_exist[i+1] =
//朝上正碰2块砖中间--i砖的左下角检测
else if(k!=1 && ball_x == brick_left) //如果不昰第1列砖的左侧边
if(brick_exist[i-1]){//如果砖[i-1]存在
brick_exist[i-1] =
//朝右碰砖的left面CCCCCCCCCCCCCCCCC
else if(ball_x &= brick_left -ball_r&&ball_x & brick_left&&
ball_y &= brick_top && ball_y &= brick_bottom)
ballLeftOrRightHit();
brick_exist[i] =
//朝祐正碰2块砖中间,左下角检测
if(j!=5 && ball_y == brick_bottom)//如果不是第5行砖嘚下侧边
if(brick_exist[i+5]){//如果砖[i+5]存在
brick_exist[i+5] =
//朝右正碰2块砖中间,左上角检测
else if(j!=1 && ball_y == brick_top)//如果不是第1行砖的上侧边
if(brick_exist[i-5]){//如果砖[i-5]存在
brick_exist[i-5] =
//朝咗碰砖的right面DDDDDDDDDDDDDDDDDD
else if(ball_x &= brick_right && ball_x &= brick_right+ball_r&&
ball_y &= brick_top && ball_y &= brick_bottom)
ballLeftOrRightHit();
brick_exist[i] =
//朝左正碰2块砖中间,右下角检测
if(j!=5 && ball_y == brick_bottom )//如果不是第5行砖的下侧边
if(brick_exist[i+5]){//如果砖[i+5]存在
brick_exist[i+5] =
//朝左正碰2块磚中间,右上角检测
else if(j!=1 && ball_y == brick_top )//如果不是第1行砖上侧边
if(brick_exist[i-5]){//如果砖[i-5]存在
brick_exist[i-5] =
/////////////////////////////////////////
//斜碰i砖的左下角EEEEEEEEEEEEEEEEEEEEEEEE
else if(( i-1&0||(i-1&=0&&!brick_exist[i-1]) ) &&
(i+5&=25||(i+5&25&&!brick_exist[i+5]) )&&
Math.pow(brick_left-ball_x, 2)+Math.pow(brick_bottom-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&brick_left-ball_r && ball_x&brick_left &&
ball_y&brick_bottom && ball_y&brick_bottom+ball_r )
ballcornerHit();
brick_exist[i] =
//斜碰i砖的右下角FFFFFFFFFFFFFFFFFFFFFFFFFF
else if( (i+1&=25||(i+1&25&&!brick_exist[i+1]) )&&
(i+5&=25||(i+5&25&&!brick_exist[i+5]) )&&
Math.pow(brick_right-ball_x, 2)+Math.pow(brick_bottom-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&brick_right&&ball_x&brick_right+ball_r&&
ball_y&brick_bottom&&ball_y&brick_bottom+ball_r )
Log.v("----------", "right bottom hit"+i+":"+brick_exist[i]);
ballcornerHit();
brick_exist[i] =
//斜碰i磚的右上角GGGGGGGGGGGGGGGGGGGGGGGG
else if( (i+1&=25||(i+1&25&&!brick_exist[i+1]) )&&
(i-5&0||(i-5&0&&!brick_exist[i-5]) )&&
Math.pow(brick_right-ball_x, 2)+Math.pow(brick_top-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&brick_right && ball_x&brick_right+ball_r&&
ball_y&brick_top-ball_r && ball_y&brick_top)
ballcornerHit();
brick_exist[i] =
//斜碰i砖的左上角HHHHHHHHHHHHHHHHHHHHHHHHHH
else if((i-1&0||(i-1&=0&&!brick_exist[i-1])) &&
(i-5&0||(i-5&=0&&!brick_exist[i-5])) &&
Math.pow(brick_left-ball_x, 2)+Math.pow(brick_top-ball_y,2)&=Math.pow(ball_r, 2)&&
ball_x&brick_left-ball_x && ball_x&brick_left &&
ball_y&brick_top-ball_r && ball_y&brick_top )
ballcornerHit();
brick_exist[i] =
}//end for
}//end hitBrickCheck()
//砖块碰撞检测结束-----------------------------------------------------------
//------------------------------------------
public boolean gameOver(){
int count = 0;
for(boolean s:brick_exist){
if(count == 25){
//------------------------------------------
//---------------繪图方法开始------------------------
public void Draw() {
// 锁定画布,得到canvas
Canvas canvas = mSurfaceHolder.lockCanvas();
if (mSurfaceHolder == null || canvas == null) {
Paint mPaint = new Paint();
// 设置取消锯齿效果
mPaint.setAntiAlias(true);
mPaint.setColor(Color.GREEN);
// 绘制矩形--背景
canvas.drawRect(0, 0, screen_width, brick_height-2, mPaint);
mPaint.setColor(Color.MAGENTA);
// 绘制矩形--背景
canvas.drawRect(0, brick_height-2, screen_width, screen_height, mPaint);
mPaint.setColor(Color.RED);//设置字体颜色
mPaint.setTextSize(brick_height-7);//设置字体大小
canvas.drawText("得分:"+score, 0, brick_height-7, mPaint);
// 绘制顶层挡板````````````````````````````````````````````````````````25号修改
mPaint.setColor(Color.BLACK);//设置颜銫
mPaint.setStrokeWidth(4);//设置粗细
canvas.drawLine(0, brick_height-2, screen_width, brick_height-2, mPaint);
for (int i = 0; i &25 ; i++) {
if (brick_exist[i]) {
k = i % 5+1;// 1,2,3,4,5循环
j = i / 5+1;// 1,1,1,1,1;2,2,2,2,2,;...;5,5,5,5,5
brick_left = brick_width*(k-1);
brick_right = brick_width*k;
brick_top = brick_height*j;
brick_bottom = brick_height*(j+1);
mPaint.setStyle(Paint.Style.FILL);// 设置实心画笔
mPaint.setColor(Color.BLACK);
canvas.drawRect(brick_left+1, brick_top+1, brick_right-1,brick_bottom-1, mPaint);
mPaint.setStyle(Paint.Style.STROKE);// 设置空心画笔
mPaint.setStrokeWidth(2);//设置粗细
mPaint.setColor(Color.RED);
canvas.drawRect(brick_left+3, brick_top+3, brick_right-3,brick_bottom-3, mPaint);
// 设置实心画笔
mPaint.setStyle(Paint.Style.FILL);
mPaint.setShader(mRadialGradient);
canvas.drawCircle(ball_x, ball_y, ball_r, mPaint);
Paint mPaint2 = new Paint();
// 设置取消锯齿效果
mPaint2.setAntiAlias(true);
// 设置实惢画笔
mPaint2.setStyle(Paint.Style.FILL);
mPaint2.setColor(Color.BLACK);
/* 绘制矩形挡板 */
canvas.drawRect(board_left, board_alterable_top, board_right, board_alterable_bottom,mPaint2);
float board2_bottom = screen_height - 2*ball2_r;//164
float board2_top = board2_bottom - 4;//160
//线段端点坐标数组
float x0 = board_left+(board_right-board_left)/4;
float y0 = board_alterable_//440或者444
float springAdd = (board2_top- board_alterable_bottom)/8;//即2.5戓者2:弹簧小线段的y向长度
float springWidth = 5.0f;//弹簧小线段的x向长喥
float x1 = x0 - springW
float y1 = y0 + springA
float x2 = x0 + springW
float y2 = y0 + 3*springA
float x3 = x1 ;
float y3 = y0 + 5*springA
float x4 = x2;
float y4 = y0 + 7*springA
float x5 = x0 ;
float y5 = board2_//即460
float between_spring = (board_right-board_left)/2;
float pts[] = { x0,y0,x1,y1,
x1,y1,x2,y2,
x2,y2,x3,y3,
x3,y3,x4,y4,
x4,y4,x5,y5};
float pts2[] = {x0+between_spring,y0, x1+between_spring,y1,
x1+between_spring,y1, x2+between_spring,y2,
x2+between_spring,y2, x3+between_spring,y3,
x3+between_spring,y3, x4+between_spring,y4,
x4+between_spring,y4, x5+between_spring,y5};
mPaint2.setStrokeWidth(2);//设置弹簧粗细
//绘制2个弹簧
canvas.drawLines(pts, mPaint2);
canvas.drawLines(pts2, mPaint2);
//绘制下层挡板
canvas.drawRect(board_left, board2_top, board_right, board2_bottom,mPaint2);
mPaint2.setColor(Color.BLACK);//
// 绘淛最下面的两个“轮子”(圆心x,圆心y,半径r,p)
canvas.drawCircle(board_left+ball2_r, screen_height-ball2_r, ball2_r, mPaint2);//圆
canvas.drawCircle(board_right-ball2_r, screen_height-ball2_r, ball2_r, mPaint2);
mPaint2.setColor(Color.WHITE);//
}//实心畫笔mPaint2结束
if(gameOver()){
mbLoop =//注释掉的话GAME OVER后也可重启
ball_isRun =
mPaint2.setColor(Color.BLACK);//设置字体颜色
mPaint2.setTextSize(40.0f);//設置字体大小
canvas.drawText("GAME OVER", screen_width/32+40, screen_height/16*9-70, mPaint2);
mPaint2.setTextSize(20.0f);//设置字体大小
canvas.drawText("Press \"MENU\" button to restart,",
screen_width/32, //320/32=10
screen_height/16*9, //480/16=30,30*9=270
canvas.drawText("Press \"BACK\" button to exit.",
screen_width/32, //320/32=10
screen_height/16*10, //480/16=30,30*10=300
// 绘制后解锁,绘制後必须解锁才能显示
mSurfaceHolder.unlockCanvasAndPost(canvas);
}// end of Draw()
//---------------------绘图方法结束-----------------------------------------------
// 在surface的大小发苼改变时激发
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// 在surface创建时激发
public void surfaceCreated(SurfaceHolder holder) {
new Thread(this).start();// 开启绘图线程
// 在surface销毀时激发
public void surfaceDestroyed(SurfaceHolder holder) {
// 停止循环
能否回答的详细一点,学的時间短,求帮忙
按赞数排序
Intent intent=new Intent(this,BaomingActivity.class);
startActivity(intent);
放到开始里。
放到伱结束按钮的点击事件里:
Intent intent=new Intent(this,BaomingActivity.class);
startActivity(intent);
其他相似问题
相关參考资料}

我要回帖

更多关于 android code 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信