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 final class R {
|
||||||
public static final class attr {
|
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 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.content.Context;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
public class Cocos2dxGLSurfaceView extends GLSurfaceView{
|
public class Cocos2dxGLSurfaceView extends GLSurfaceView {
|
||||||
private static final String TAG = Cocos2dxGLSurfaceView.class
|
private static final String TAG = Cocos2dxGLSurfaceView.class
|
||||||
.getCanonicalName();
|
.getCanonicalName();
|
||||||
private Cocos2dxRenderer mRenderer;
|
private Cocos2dxRenderer mRenderer;
|
||||||
|
@ -14,6 +15,15 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView{
|
||||||
|
|
||||||
public Cocos2dxGLSurfaceView(Context context) {
|
public Cocos2dxGLSurfaceView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
mRenderer = new Cocos2dxRenderer();
|
mRenderer = new Cocos2dxRenderer();
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
setRenderer(mRenderer);
|
setRenderer(mRenderer);
|
||||||
|
|
|
@ -3,20 +3,30 @@ package org.cocos2dx.tests;
|
||||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
||||||
|
|
||||||
|
|
||||||
import android.opengl.GLSurfaceView;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class TestsDemo extends Cocos2dxActivity{
|
public class TestsDemo extends Cocos2dxActivity{
|
||||||
protected void onCreate(Bundle savedInstanceState){
|
private Cocos2dxGLSurfaceView mGLView;
|
||||||
|
|
||||||
|
protected void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// get the packageName,it's used to set the resource path
|
// get the packageName,it's used to set the resource path
|
||||||
String packageName = getApplication().getPackageName();
|
String packageName = getApplication().getPackageName();
|
||||||
super.setPackgeName(packageName);
|
super.setPackgeName(packageName);
|
||||||
|
|
||||||
mGLView = new Cocos2dxGLSurfaceView(this);
|
setContentView(R.layout.test_demo);
|
||||||
setContentView(mGLView);
|
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
|
@Override
|
||||||
|
@ -36,8 +46,6 @@ public class TestsDemo extends Cocos2dxActivity{
|
||||||
android.os.Process.killProcess(android.os.Process.myPid());
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private GLSurfaceView mGLView;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("cocosdenshion");
|
System.loadLibrary("cocosdenshion");
|
||||||
System.loadLibrary("chipmunk");
|
System.loadLibrary("chipmunk");
|
||||||
|
|
Loading…
Reference in New Issue