需要在SurfaceView中弹出对话框,无法直接实现,避免是SurfaceView线程中修改UI。
折中的解决办法:在创建SurfaceView时会得到Context,使用其中的holder就可以弹出Dialog了。
备忘:
//自定义绘图方法
public void myDraw(){
//game over
if(player.live<=0){
flag=false;
context.hanlder.post(new Runnable(){
public void run() {
context.showDialog();
}
});
return;
}