Merge branch 'inflateViews' of https://github.com/Macarse/cocos2d-x into Macarse-inflateViews

This commit is contained in:
minggo 2011-04-12 15:12:48 +08:00
commit 8e85f56f97
4 changed files with 75 additions and 35 deletions

View File

@ -10,7 +10,13 @@ package org.cocos2dx.tests;
public final class R {
public static final class attr {
}
public static final class id {
public static final int test_demo_gl_surfaceview=0x7f040000;
}
public static final class layout {
public static final int test_demo=0x7f020000;
}
public static final class string {
public static final int app_name=0x7f020000;
public static final int app_name=0x7f030000;
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Cocos2d-x"/>
<org.cocos2dx.lib.Cocos2dxGLSurfaceView
android:id="@+id/test_demo_gl_surfaceview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -2,11 +2,12 @@ package org.cocos2dx.lib;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
public class Cocos2dxGLSurfaceView extends GLSurfaceView{
public class Cocos2dxGLSurfaceView extends GLSurfaceView {
private static final String TAG = Cocos2dxGLSurfaceView.class
.getCanonicalName();
private Cocos2dxRenderer mRenderer;
@ -14,6 +15,15 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView{
public Cocos2dxGLSurfaceView(Context context) {
super(context);
initView();
}
public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
private void initView() {
mRenderer = new Cocos2dxRenderer();
setFocusableInTouchMode(true);
setRenderer(mRenderer);

View File

@ -3,20 +3,30 @@ package org.cocos2dx.tests;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
public class TestsDemo extends Cocos2dxActivity{
protected void onCreate(Bundle savedInstanceState){
private Cocos2dxGLSurfaceView mGLView;
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// get the packageName,it's used to set the resource path
String packageName = getApplication().getPackageName();
super.setPackgeName(packageName);
mGLView = new Cocos2dxGLSurfaceView(this);
setContentView(mGLView);
setContentView(R.layout.test_demo);
mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.test_demo_gl_surfaceview);
// Get the size of the mGLView after the layout happens
mGLView.post(new Runnable() {
@Override
public void run() {
Cocos2dxActivity.screenHeight = mGLView.getHeight();
Cocos2dxActivity.screenWidth = mGLView.getWidth();
}
});
}
@Override
@ -36,8 +46,6 @@ public class TestsDemo extends Cocos2dxActivity{
android.os.Process.killProcess(android.os.Process.myPid());
}
private GLSurfaceView mGLView;
static {
System.loadLibrary("cocosdenshion");
System.loadLibrary("chipmunk");