如何在触摸屏幕底部时启动另一个 Activity? - Android Studio 2d 游戏

问题描述

我正在制作一个类似于 Flappy Bird 的 2d 游戏。当角色(位图)落到屏幕底部时,我想打开另一个活动(游戏结束活动)。

我试过了,但是不行

 private int screenHeight = Resources.getSystem().getdisplayMetrics().heightPixels;

    if(diverY > screenHeight){

        Intent gameOverIntent = new Intent(getContext(),GameOverActivity.class);
        gameOverIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        gameOverIntent.putExtra("score",score);

        getContext().startActivity(gameOverIntent);
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)