way for a HUD

Started by coersum, October 13, 2012, 06:25:22 AM

Previous topic - Next topic

coersum

Hi,

I found this online and figured I'd share it, I just started programing using JPCT-AE and having limited knowledge in java, I experiment a lot.
I wanted to add a HUD of some sort but didn't understand how to "blit" as I read here and there so I searched and found this, please let me know if this will bug or slow down the device:

in HelloWorld demo:

replace:
mGLView = new GLSurfaceView(getApplication());
with

setContentView(R.layout.activity_main); //or whatever the layout you want to use
mGLView = (GLSurfaceView) findViewById(R.id.graphics_glsurfaceview1);


remove
setContentView(mGLView);

now in your layout copy/paste:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/graphics_frameLayout1"
    android:layout_width="fill_parent"
    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:id="@+id/HUD"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center|bottom"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/icon" />

    </LinearLayout>
</FrameLayout>


After that play around with placements.

Source where I found it and what it does (2 overlays, 1 for inventory and 1 for hud).
http://stackoverflow.com/questions/8128896/mixing-android-views-and-glsurfaceview


Doing this will keep you from having to blit or making your own opengl, however I don't know enough to know if it will have any undesirable consequences, please let me know.

EgonOlsen

You can do this, if you want to. As long as you get it working, everything should be fine. The engine itself doesn't care about this. "blit" means to use the blit-methods in FrameBuffer to create a hud from texture images by copying parts of them to the screen (=blit (block image transfer) them). This gui at http://www.jpct.net/forum2/index.php/topic,2471.msg22110.html#msg22110 is done that way for example.