問(wèn)題描述
我目前正在開(kāi)發(fā)一款游戲,我不想在進(jìn)行到一半時(shí)發(fā)現(xiàn)我正在做的事情會(huì)導(dǎo)致錯(cuò)誤/扼殺性能.這就是我正在考慮的設(shè)置方式.
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.
首先想要一個(gè)帶有一個(gè)包含 HUD 的 LinearLayout 的 LinearLayout,然后是一個(gè) GLSurfaceView.但是我可能會(huì)在某些時(shí)候暫停"游戲視圖并切換到包含庫(kù)存或裝備等的不同線性布局.
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.
我認(rèn)為這種方式最好,因?yàn)槲铱梢岳?android 自帶的所有優(yōu)秀組件,而不是使用 OpenGL 自己制作.但是我擔(dān)心混合這兩種視圖可能會(huì)出現(xiàn)一些問(wèn)題.任何見(jiàn)解或建議將不勝感激.謝謝.
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 作為第一個(gè)元素的 FrameLayout.IE.在堆棧的底部,其他視圖/視圖組位于其頂部.我建議只是暫停游戲循環(huán)并在其頂部放置一些不透明的視圖以隱藏它,而不是交換視圖或其他任何東西:
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>
這篇關(guān)于混合 Android 視圖和 GLSurfaceView的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!