不能在Cocos2d-x中“Hello World”

时间:2014-05-26 09:46:51

标签: java android eclipse cocos2d-x emulation

我正在尝试为某些游戏开发设置Cocos2d-x。在创建默认的Hello World项目并将Cocos2d-x库导入Eclipse之后,当我尝试在模拟器上运行应用程序时,它崩溃了。请帮忙。

我在模拟器中启用了GPU模拟,在清单文件中添加了OpenGLES 2.0权限。

package com.toddperkins.MoleItx;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import android.os.Bundle;

public class MoleItx extends Cocos2dxActivity{

protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState); 
}

public Cocos2dxGLSurfaceView onCreateView() {
    Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
    // MoleItx should create stencil buffer
    glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);

    return glSurfaceView;
}

static {
    System.loadLibrary("cocos2dcpp");
}     
}

LogCat:

`05-26 15:06:18.048: D/dalvikvm(453): Added shared lib/ data/data/com.toddperkins.MoleItx/lib/libcocos2dcpp.so 0x405132a8
 05-26 15:06:18.246: D/Cocos2dxActivity(453): model=sdk
 05-26 15:06:18.246: D/Cocos2dxActivity(453): product=sdk
 05-26 15:06:18.246: D/Cocos2dxActivity(453): isEmulator=true
 05-26 15:06:18.716: D/libEGL(453): egl.cfg not found, using default config
 05-26 15:06:18.716: D/libEGL(453): loaded /system/lib/egl/libGLES_android.so
 05-26 15:06:18.861: W/dalvikvm(453): threadid=9: thread exiting with uncaught exception (group=0x40015560)
 05-26 15:06:18.866: E/AndroidRuntime(453): FATAL EXCEPTION: GLThread 10
 05-26 15:06:18.866: E/AndroidRuntime(453): java.lang.IllegalArgumentException: No configs match configSpec
 05-26 15:06:18.866: E/AndroidRuntime(453):     at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:763)
 05-26 15:06:18.866: E/AndroidRuntime(453):     at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:919)
 05-26 15:06:18.866: E/AndroidRuntime(453):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1264)
 05-26 15:06:18.866: E/AndroidRuntime(453):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
 05-26 15:11:19.011: I/Process(453): Sending signal. PID: 453 SIG: 9`

1 个答案:

答案 0 :(得分:1)

StackOverflow上的另一个Cocos2d-x用户

Petr能够通过setting his GL configuration explicitly修复此问题,并添加:

gLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);

gLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());