Search code examples
androidcocos2d-android

CCGLSurfaceView Error


I'm developing some sample code. I had some problem using cocos2d. That is the CCGLSurfaceView problem.

Firstly, I imported cocos2d.jar in my project with fps_images.png file. And i modify my project for using the cocos2d library.

Here are the code.

public class ToadActivity extends Activity {

protected CCGLSurfaceView _glSurfaceView;

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    _glSurfaceView = new CCGLSurfaceView(this);

    setContentView(_glSurfaceView);
}
@Override
public void onStart()
{
    super.onStart();

    CCDirector.sharedDirector().attachInView(_glSurfaceView);

    CCDirector.sharedDirector().setDisplayFPS(true);

    CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
}
}

==>>> _glSurfaceView = new CCGLSurfaceView(this);

Here, My application found a error. And at the result, it is killed in my android simulator. What's the problem?


Solution

  • That library are decreated, not update more. It will be better start using: http://www.cocos2d-x.org/. It use c++, to work on android, use JNI (Native code). Code can be ported to other plataforms, like IOs.

    Hope it help!