Scaling issue in Cocos2D

165 Views Asked by At

I am creating a game in cocos2D android. My problem is when the app resumes after going to background, my app images scaling changes and everything becomes big instead of what I have set initially.

When I stop this game and restart it, then there is no problem. Is that the problem with Cocos2d? or what should I do to resolve this problem? because I want the resume capability in my game.

1

There are 1 best solutions below

0
On

Have you added bottom methods with in you activity from you are starting cocos2d scene

@Override
public void onStop() {
    super.onStop();
    CCDirector.sharedDirector().end();
}
@Override
public void onPause() {
    super.onPause();
    CCDirector.sharedDirector().pause();
}
@Override
public void onResume() {
    super.onResume();
    CCDirector.sharedDirector().resume();
}
@Override
public void onDestroy() {
    super.onDestroy();
}
@Override
public void onStart() {
    super.onStart();
    CCDirector.sharedDirector().attachInView(_glSurfaceView);
    CCDirector.sharedDirector().setLandscape(false);
    CCDirector.sharedDirector().setDisplayFPS(true);
    CCDirector.sharedDirector().setAnimationInterval(1.0f / 60);
            scene = GameLayer1.scene();
        CCDirector.sharedDirector().runWithScene(scene);}
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    Bundle extras = getIntent().getExtras();

    _glSurfaceView = new CCGLSurfaceView(this);
    setContentView(_glSurfaceView);
}