android平台俄罗斯方块游戏完整代码
2012-12-02 14:31:58 来源:WEB开发网核心提示:} 下面是显示开始图片按钮MenuView.java,代码如下: package com.example.eluosifangkuai;import android.content.Context;import android.graphics.Canvas;import android.view.View;publi
}
下面是显示开始图片按钮MenuView.java,代码如下:
package com.example.eluosifangkuai;
public class MenuView extends View{
ImageButton m_ImageButton_Play; // 开始播放按钮
ImageButton m_ImageButton_Play_a;
ImageButton m_bg; // 背景图片
public MenuView(Context context) { // 初始化工作
super(context);
m_bg = new ImageButton(context,R.drawable.b7,0,0);
m_ImageButton_Play = new ImageButton(context,R.drawable.play,62,136);
m_ImageButton_Play_a = new ImageButton(context,R.drawable.play1,62,136);
}
public void onDraw(Canvas canvas) // 画布中显示位图
{
m_bg.DrawImageButton(canvas, null);
m_ImageButton_Play.DrawImageButton(canvas, null);
}
}
ImageButton m_ImageButton_Play_a;
ImageButton m_bg; // 背景图片
public MenuView(Context context) { // 初始化工作
super(context);
m_bg = new ImageButton(context,R.drawable.b7,0,0);
m_ImageButton_Play = new ImageButton(context,R.drawable.play,62,136);
m_ImageButton_Play_a = new ImageButton(context,R.drawable.play1,62,136);
}
public void onDraw(Canvas canvas) // 画布中显示位图
{
m_bg.DrawImageButton(canvas, null);
m_ImageButton_Play.DrawImageButton(canvas, null);
}
}
还有一个启动活动类,MainActivity.java 代码为:
package com.example.eluosifangkuai;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends Activity {
private static final int GOTO_MAIN_ACTIVITY = 0; // 发送消息参数
private Handler mHandler = new Handler(){ // 消息推送类
public void handleMessage(android.os.Message msg) {
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends Activity {
private static final int GOTO_MAIN_ACTIVITY = 0; // 发送消息参数
private Handler mHandler = new Handler(){ // 消息推送类
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Log.i("yunxing","OK2222");
Intent intent = new Intent();
intent.setClass(MainActivity.this, WelcomeActivity.class); // 活动跳转
startActivity(intent);
Log.i("yunxing","ERROR");
finish();
break;
case GOTO_MAIN_ACTIVITY:
Log.i("yunxing","OK2222");
Intent intent = new Intent();
intent.setClass(MainActivity.this, WelcomeActivity.class); // 活动跳转
startActivity(intent);
Log.i("yunxing","ERROR");
finish();
break;
更多精彩
赞助商链接