安卓飞机大战(四) 实现从MysurfaceView到 Activity的跳转

发布时间:2020-08-02 23:52:03 作者:JustMetU
来源:网络 阅读:1308

从一个Activity到另一个Acitvity是简单的

但是怎么从自己写的surfaceview跳转到一个Activity呢?

在 MysurfaceView (extends SurfaceView)中:


public class GameView extends SurfaceView implements SurfaceHolder.Callback,Runnable{


private Context context=this.getContext();

private boolean endback=true;//定义一个布尔值,标志当前游戏是否结束

public boolean onTouchEvent(MotionEvent event) {
        if(endback&&event.getAction()==MotionEvent.ACTION_DOWN){//游戏结束并且点击屏幕
        Intent intent =new Intent(context,endActivity.class);//跳转
            context.startActivity(intent);

            System.exit(0);//结束当前页面
        }
      
        return true;
    }



这样就可以实现在游戏结束跳转页面啦!


推荐阅读:
  1. 安卓控制LED驱动编写
  2. VideoPlayer与安卓

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

surfaceview layout sur ce

上一篇:Oracle固定SQL的执行计划(一)---SQL Profile

下一篇:Exchange 2016 允许通讯组所有者管理成员

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》