//定义菜单类,接口为 OnClickListener,用于接收用户的单击消息。
public class StartActivity extends Activity implements View.OnClickListener
//设计 5 个按钮用于接收按钮消息:
private Button btnStart;
private Button btnSet;
private Button btnRole;
private Button btnAbout;
private Button btnExit;
//在 OnCreate 函数中将它们初始化:
//获取按钮
btnStart = (Button)findViewById(R.id.btnStart);
btnSet = (Button)findViewById(R.id.btnSet);
btnRole = (Button)findViewById(R.id.btnRole);
btnAbout = (Button)findViewById(R.id.btnAbout);
btnExit = (Button)findViewById(R.id.btnExit);
//注册点击事件
btnStart.setOnClickListener(this);
btnSet.setOnClickListener(this);
btnRole.setOnClickListener(this);
btnAbout.setOnClickListener(this);
btnExit.setOnClickListener(this);
在 OnClick 函数中对响应进行处理:
setContentView(new GameView(this)); //进入游戏,游戏在 GameView 类中进行了封
装
//说明游戏规则
new AlertDialog.Builder(this).setMessage("1. 将相同的两张图片用三根以内的直线连在
一起就可以消除\n" +
"2. 每消除一次图片,都会使可用时间增加\n" + "3. 每隔一段时间,
当前的界面中的图片会进行重排列\n" +
"4. 在规定的时间里,当所有的图片都消除时,即为胜利\n" + "5. 规
定的时间内有图片未消去,即为失败\n")
.setPositiveButton("确定", null).show();
//结束游戏
this.finish();
//进行游戏设置,设置游戏的难度,调用了 SetActivity 类
intent.setClass(this, SetActivity.class);
3.7、接口
API 函数
3.8、限制条件
无明显限制条件
4、界面设计说明
评论3