Black Screen on Android Launch Unless using Landscape Orientation

前端 未结 1 1851
感动是毒
感动是毒 2021-01-20 04:00

Using a Nexus 5 (and any of the later android handsets such as Galaxy S5 etc) my game which previously worked fine on other devices, simply shows a black screen when launche

相关标签:
1条回答
  • 2021-01-20 04:24

    This is a issue of cocos2d for Android 4.3 and above Issue raised and answered at github forum

    Though there are many work around like putting the below code in onStart() method.

    app.metric = 1;
    CGSize s = CCDirector.sharedDirector().winSize();
    if (s.height > 1280) {
        app.metric = s.height / 1280;
        s.height = s.height / app.metric;
        s.width = s.width / app.metric;
        CCDirector.sharedDirector().setScreenSize((int) s.width, (int) s.height);
    }
    

    or if you have the source code of cocos2d then change the line mentioned below.

    public static final int kCCDirectorProjectionDefault = kCCDirectorProjection3D;
    

    or you can implement this solution

    In CCDirector's setProjection Method - Change gluPerspective to 2000 instead of 1500 New Line will be like this - GLU.gluPerspective(gl, 60, size.width/size.height, 0.5f, 2000.0f);

    But all this are work around for the issue, so if you really want good solution then you can get the latest cocos2d jar or source code and implement in your app.

    0 讨论(0)
提交回复
热议问题