問題描述
我目前正在開發一款游戲,我不想在進行到一半時發現我正在做的事情會導致錯誤/扼殺性能.這就是我正在考慮的設置方式.
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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!