Android编程之无聊的“捏泡泡”游戏
2010-05-08 08:50:00 来源:WEB开发网}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 0:
reset();
return false;
case 1:
about();
return false;
case 2:
destory();
return false;
default:
return false;
}
}
public void onBackPressed(){
destory();
super.onBackPressed();
}
/**
* 重新开始
*/
public void reset(){
int i,l=vcl.length;
for(i=0;i
vcl[i].reset();
}
}
/**
* 销毁对象,释放资源
*/
public void destory(){
sound.destroy();
this.finish();
}
/**
* 初始化每一行的泡泡
*/
private void initRows(){
int i,l=rowCount;
TableLayout container=(TableLayout)findViewById(R.id.container2);
for(i=0;i
rows[i]=new TableRow(this);
container.addView(rows[i]);
}
}
/**
* 初始化内容的呈现
*/
private void initRender(){
int cr,i,l=vcl.length;
initRows();
for(i=0;i
cr=(int)Math.ceil(i/cellCount);
vcl[i]=new Vacuole(this,sound);
rows[cr].addView(vcl[i].renderer, 46, 46);
}
}
/**
* about对话框的定义
*/
private void about(){
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.about);
dialog.setTitle("随机出品");
dialog.show();
}
}
Vacuole类
package randork.game;
import android.content.Context;
import android.view.MotionEvent;
更多精彩
赞助商链接