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 launched, the buttons can be clicked (even though you cannot see them) and the sfx plays.
Having struggled massively with this problem, I somehow managed to fix it to some degree this is the code that matters regarding the launch;
mGLSurfaceView = new CCGLSurfaceView(this);
CCDirector.sharedDirector().setScreenSize(CCDirector.sharedDirector().winSize().width,
CCDirector.sharedDirector().winSize().height);
CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationPortrait);
CCDirector.sharedDirector().getActivity().setContentView(mGLSurfaceView, createLayoutParams());
InitParam();
With the following code above, shows a black screen on launch (the splash screen graphic DOES show but the main gameactivity screen does not).
However, by changing this line;
CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationPortrait);
to
CCDirector.sharedDirector().setDeviceOrientation(CCDirector.kCCDeviceOrientationLandscapeLeft);
The app displays - albeit stretched out graphics and not ideal! So this seems to be a resolution issue due to the newer android devices. Having searched I could find snippets of code relating to 'gluPerspective' but I do not have that in my code to change.
The Nexus / Galaxy has resolutions up to 1920 I believe, so somehow need to find a way to set that to work with the existing code.
Additional code which may help, from the TitleLayer
public TitleLayer()
{
super();
CCSprite sprite = CCSprite.sprite(G._getImg("background"));
G.setScale(sprite);
sprite.setAnchorPoint(0, 0);
sprite.setPosition(0, 0);
addChild(sprite);
isTouchEnabled_= true;
}
public static void setScale(){
G._scaleX = CCDirector.sharedDirector().winSize().width / G.WIN_W;
G._scaleY = CCDirector.sharedDirector().winSize().height / G.WIN_H;
}
And it gets the values from here;
public static Activity g_Context;
public static final float DEFAULT_W = 360f;
public static final float DEFAULT_H = 480f;
public static final float WIN_W = 720f;
public static final float WIN_H = 1280f;
public static void getScale(){
_scaleX = CCDirector.sharedDirector().winSize().width / WIN_W;
_scaleY = CCDirector.sharedDirector().winSize().height / WIN_H;
}
public static float _getX(float x) {
return _scaleX * x;
}
public static float _getY(float y) {
return _scaleY * y;
}
public static void setScale(CCNode node) {
node.setScaleX(_scaleX);
node.setScaleY(_scaleY);
}
public static void setScale(CCNode node, float scaleFactor) {
node.setScaleX(_scaleX*scaleFactor);
node.setScaleY(_scaleY*scaleFactor);
}
public static void setScale(CCNode node, boolean bSmall) {
float scale = bSmall ?
(_scaleX<_scaleY ? _scaleX : _scaleY) :
(_scaleX>_scaleY ? _scaleX : _scaleY);
node.setScale(scale);
}