混合 Android 视图和 GLSurfaceView

Mixing Android Views and GLSurfaceView(混合 Android 视图和 GLSurfaceView)
本文介绍了混合 Android 视图和 GLSurfaceView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我目前正在开发一款游戏,我不想在进行到一半时发现我正在做的事情会导致错误/扼杀性能.这就是我正在考虑的设置方式.

I'm currently working on a game and I would hate to get halfway through and find that the what I'm doing causes errors/kills performance. This is how I'm thinking of setting it up.

首先想要一个带有一个包含 HUD 的 LinearLayout 的 LinearLayout,然后是一个 GLSurfaceView.但是我可能会在某些时候暂停"游戏视图并切换到包含库存或装备等的不同线性布局.

First want to have a LinearLayout with a LinearLayout containing a HUD, and then a GLSurfaceView. However I may at certain points "pause" the game view and switch to a different linear layout containing an inventory or equips, etc.

我认为这种方式最好,因为我可以利用 android 自带的所有优秀组件,而不是使用 OpenGL 自己制作.但是我担心混合这两种视图可能会出现一些问题.任何见解或建议将不胜感激.谢谢.

I think this way would be best because I can make use of all the great components that android comes with rather than making my own with OpenGL. However I am worried that mixing the two types of view may have some problems. Any insight or suggestions would be greatly appreciated. Thanks.

推荐答案

我一直在使用带有 GLSurfaceView 作为第一个元素的 FrameLayout.IE.在堆栈的底部,其他视图/视图组位于其顶部.我建议只是暂停游戏循环并在其顶部放置一些不透明的视图以隐藏它,而不是交换视图或其他任何东西:

I've been using a FrameLayout with the GLSurfaceView as the first element. I.e. at the bottom of the stack, with other views / viewgroups layered over the top of it. I'd recommend just pausing the game-loop and placing some opaque view over the top of it to hide it rather than swapping views in and out or whatever:

<FrameLayout 
    android:id="@+id/graphics_frameLayout1" 
    android:layout_width="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent">
    <android.opengl.GLSurfaceView 
        android:id="@+id/graphics_glsurfaceview1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent">
    </android.opengl.GLSurfaceView>
    <LinearLayout 
        android:layout_height="fill_parent" 
        android:id="@+id/inventory" 
        android:gravity="center" 
        android:layout_width="fill_parent" 
        android:orientation="vertical"
        android:visibility="gone">
    </LinearLayout>
    <LinearLayout 
        android:layout_height="fill_parent" 
        android:id="@+id/HUD" 
        android:gravity="center" 
        android:layout_width="fill_parent" 
        android:orientation="vertical">
    </LinearLayout>
</FrameLayout>

这篇关于混合 Android 视图和 GLSurfaceView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Show progress during FTP file upload in a java applet(在 Java 小程序中显示 FTP 文件上传期间的进度)
How to copy a file on the FTP server to a directory on the same server in Java?(java - 如何将FTP服务器上的文件复制到Java中同一服务器上的目录?)
FTP zip upload is corrupted sometimes(FTP zip 上传有时会损坏)
Enable logging in Apache Commons Net for FTP protocol(在 Apache Commons Net 中为 FTP 协议启用日志记录)
Checking file existence on FTP server(检查 FTP 服务器上的文件是否存在)
FtpClient storeFile always return False(FtpClient storeFile 总是返回 False)