mirror of https://github.com/axmolengine/axmol.git
Merge branch 'inflateViews' of https://github.com/Macarse/cocos2d-x into Macarse-inflateViews
This commit is contained in:
commit
8e85f56f97
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
|
@ -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);
|
||||
|
|
|
@ -3,11 +3,11 @@ 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{
|
||||
private Cocos2dxGLSurfaceView mGLView;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
@ -15,8 +15,18 @@ public class TestsDemo extends Cocos2dxActivity{
|
|||
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");
|
||||
|
|
Loading…
Reference in New Issue