在iPad视网膜显示器的黑屏 [英] Black screen on iPad retina display

查看:175
本文介绍了在iPad视网膜显示器的黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在iPad上运行的小游戏应用程序的问题。当我吃iPad模拟器iOS 5.1与iPad视网膜显示,应用程序开始与我的默认图像@ X2和之后显示图像转到黑色屏幕。在正常的iPad iOS 5.1模拟器运行良好。 Xcode只告诉我这个:

  2012-04-25 14:24:26.978 AppName [83696:10a03] cocos2d: :1 
2012-04-25 14:24:26.980 AppName [83696:10a03] cocos2d:surface size:1536x2048

有什么想法吗?
谢谢






@Smamim Hossain:同样的错误我把我的完整Appdelegate.m

  #importcocos2d.h

#importAppDelegate.h
#importGameConfig。 h
#importIntro.h
#importRootViewController.h

@implementation AppDelegate

@synthesize window;

- (void)removeStartupFlicker
{

//#如果GAME_AUTOROTATION == kGameAutorotationUIViewController


//#endif // GAME_AUTOROTATION == kGameAutorotationUIViewController
}
- (void)applicationDidFinishLaunching:(UIApplication *)application

[director setProjection:kCCDirectorProjection2D]
{


//初始化窗口
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


if(![CCDirector setDirectorType:kCCDirectorTypeDisplayLink])
[CCDirector setDirectorType:kCCDirectorTypeDefault];

[director setProjection:kCCDirectorProjection2D]
CCDirector * director = [CCDirector sharedDirector];

//初始化视图控制器
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;

//
//手动创建EAGLView
// 1.创建RGB565格式。备选:RGBA8
// 2.深度格式为0位。使用16或24位的3d效果,如CCPageTurnTransition
//
//
EAGLView * glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];

// //在iPhone 4上启用高分辨率模式(Retina显示),并在所有其他设备上保持低分辨率
if(![director enableRetinaDisplay:YES])
CCLOG (@Retina Display不支持);


#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif

[director setAnimationInterval:1.0 / 60];
[director setDisplayFPS:NO];
[director setDepthTest:NO];

//使OpenGLView成为视图控制器的子对象
[viewController setView:glView];

//使View Controller成为主窗口的子窗口
[window addSubview:viewController.view];

[window makeKeyAndVisible];

// PNG / BMP / TIFF / JPEG / GIF图像的默认纹理格式
//它可以是RGBA8888,RGBA4444,RGB5_A1,RGB565
//您可以随时更改。
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];


//删除启动闪烁
[self removeStartupFlicker];

//运行介绍场景
[[CCDirector sharedDirector] runWithScene:[Intro scene]];
}


- (void)applicationWillResignActive:(UIApplication *)application {
[[CCDirector sharedDirector] pause];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
[[CCDirector sharedDirector] resume];
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[CCDirector sharedDirector] purgeCachedData];
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
[[CCDirector sharedDirector] stopAnimation];
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
[[CCDirector sharedDirector] startAnimation];
}

- (void)applicationWillTerminate:(UIApplication *)application {
CCDirector * director = [CCDirector sharedDirector];

[[director openGLView] removeFromSuperview];

[viewController release];

[window release];

[director end];
}

- (void)applicationSignificantTimeChange:(UIApplication *)application {
[[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}

- (void)dealloc {
[[CCDirector sharedDirector] end];
[window release];
[super dealloc]
}

@end


解决方案>

尝试这行代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:



[director setProjection:kCCDirectorProjection2D];



希望这会解决您的问题。


I've a problem with a little game application running on iPad. When I lunch the simulator iOS 5.1 with iPad retina display, the application start with my default image @x2 and after show the image go to a black screen. In normal iPad iOS 5.1 simulator run well. Xcode tell me only this:

2012-04-25 14:24:26.978 AppName[83696:10a03] cocos2d: Frame interval: 1
2012-04-25 14:24:26.980 AppName[83696:10a03] cocos2d: surface size: 1536x2048

Any idea? Thank you


@Smamim Hossain: Same error I put my full Appdelegate.m

#import "cocos2d.h"

#import "AppDelegate.h"
#import "GameConfig.h"
#import "Intro.h"
#import "RootViewController.h"

@implementation AppDelegate

@synthesize window;

- (void) removeStartupFlicker
{

//#if GAME_AUTOROTATION == kGameAutorotationUIViewController


//#endif // GAME_AUTOROTATION == kGameAutorotationUIViewController  
}
- (void) applicationDidFinishLaunching:(UIApplication*)application

[director setProjection:kCCDirectorProjection2D]
{


    // Init the window
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


    if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
        [CCDirector setDirectorType:kCCDirectorTypeDefault];

    [director setProjection:kCCDirectorProjection2D]
    CCDirector *director = [CCDirector sharedDirector];

    // Init the View Controller
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
    viewController.wantsFullScreenLayout = YES;

    //
    // Create the EAGLView manually
    //  1. Create a RGB565 format. Alternative: RGBA8
    //  2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition
    //
    //
    EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
                                   pixelFormat:kEAGLColorFormatRGB565   // kEAGLColorFormatRGBA8
                                   depthFormat:0                        // GL_DEPTH_COMPONENT16_OES
                        ];

//  // 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:kCCDeviceOrientationLandscapeLeft];
#endif

    [director setAnimationInterval:1.0/60];
    [director setDisplayFPS:NO];
    [director setDepthTest:NO];

    // make the OpenGLView a child of the view controller
    [viewController setView:glView];

    // make the View Controller a child of the main window
    [window addSubview: viewController.view];

    [window makeKeyAndVisible];

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change anytime.
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];


    // Removes the startup flicker
    [self removeStartupFlicker];

    // Run the intro Scene
    [[CCDirector sharedDirector] runWithScene: [Intro scene]];
}


- (void)applicationWillResignActive:(UIApplication *)application {
    [[CCDirector sharedDirector] pause];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[CCDirector sharedDirector] resume];
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    [[CCDirector sharedDirector] purgeCachedData];
}

-(void) applicationDidEnterBackground:(UIApplication*)application {
    [[CCDirector sharedDirector] stopAnimation];
}

-(void) applicationWillEnterForeground:(UIApplication*)application {
    [[CCDirector sharedDirector] startAnimation];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    CCDirector *director = [CCDirector sharedDirector];

    [[director openGLView] removeFromSuperview];

    [viewController release];

    [window release];

    [director end]; 
}

- (void)applicationSignificantTimeChange:(UIApplication *)application {
    [[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}

- (void)dealloc {
    [[CCDirector sharedDirector] end];
    [window release];
    [super dealloc];
}

@end

解决方案

try this line of code at - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:

[director setProjection:kCCDirectorProjection2D];

hope this will fix your issue.

这篇关于在iPad视网膜显示器的黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆