我有另一个奇怪的问题,我无法在合理的时间内解决。我的应用程序在iPhone 4S和iPod 4上运行良好,有和没有启用视网膜。它也适用于没有视网膜的iPad3。但是当iPad启用了视网膜时,CCSprites就不会出现了。我确实有相机图像底衬,但它上面没有图形。我想我可以使用所有“-hd”版本的文件,它们也可以在iPhone上以视网膜模式显示。
我粘贴了我认为相关的代码:
- (void) applicationDidFinishLaunching:(UIApplication*)applicationv{
CCLOG(@"applicationDidFinishLaunching");
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeDefault];
CCDirector *director = [CCDirector sharedDirector];
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setOpenGLView:glView];
// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
#endif
[director setAnimationInterval:1.0/20];
[director setDisplayFPS:NO];
[viewController setView:glView];
[window addSubview: viewController.view];
[CCDirector sharedDirector].openGLView.backgroundColor = [UIColor clearColor];
[CCDirector sharedDirector].openGLView.opaque = NO;
glClearColor(0.0, 0.0, 0.0, 0.0);
_cameraView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_cameraView.opaque = NO;
_cameraView.backgroundColor=[UIColor clearColor];
[window addSubview:_cameraView];
_imageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[_cameraView addSubview:_imageView];
[window bringSubviewToFront:viewController.view];
[window makeKeyAndVisible];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
CCScene *scene = [CCScene node];
_layer =[[[HelloWorldLayer alloc] init] autorelease];
_menu =[MenuScene node];
[scene addChild:_layer];
[_layer addChild:_menu];
viewController.fdLayer = _layer;
_layer.root = viewController;
[[CCDirector sharedDirector] runWithScene: scene];
和MenuScene.m:
@implementation MenuScene
+(id) scene {
CCScene* scene = [CCScene node];
CCLayer* layer = [MenuScene node];
[scene addChild:layer];
return scene;
}
-(id) init {
if ((self = [super init])) {
CCLOG(@"init %@", self);
CGSize screen = [[CCDirector sharedDirector] winSize];
CCLOG(@"%f %f",screen.width,screen.height);
CCLayerColor *b = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 100) width:screen.width height:screen.height/4];
b.isRelativeAnchorPoint=YES;
b.anchorPoint=ccp(0, 1); // left top corner
b.position=ccp(0, screen.height);
[self addChild:b];
CCSprite* bg = [CCSprite spriteWithFile:@"01-main-logo.png"];
bg.position = CGPointMake(screen.width / 2, screen.height*0.12);
[b addChild:bg];
编辑:我做了临时黑客攻击:
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
}
但问题仍然存在 - 为什么?
答案 0 :(得分:0)
问题解决了。 “Make Clean”还不够。按“清洁”时按住“选项”按钮可以强制清除。之后事情开始起作用了。也有可能它与“压缩PNG文件”设置有关,我在问题开始后改为“否”,但可能没有强制执行。无论如何问题消失了,感谢收看:)