紧急,bug。default log 和第一个scene会黑屏

@jare
cocos 1.3.1 版本
经测试,新建一个工程,新建一个场景,一张背景图一个文字,打包ios平台,设置 default log(ios默认启动页面)。ios运行时,默认的启动页面和第一个scene之间会闪一下(黑屏)。求各位大大的解决方案!
http://forum.cocos.com/t/cocos-creator-ios-default-log/42957

是因为进入游戏后就加载第一个界面,但是!加载界面是异步的。。。。。

可以在c++里面先run一个场景,再加载js代码

楼主您解决了吗?我也遇到了类似的问题,求解惑,如何在c++中先run一个场景

请问如何在c++中先run一个场景

@panda @jare

请问有解决方案了吗?

折腾了一个解决方案,供参考,内容都在代码里,不多说了

static AppController* _appController = nil;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    _appController = self;
    // Override point for customization after application launch.
    
    [self loadGameBackground];
    
    [self showSplashScreen];
    
    [window makeKeyAndVisible];
    
    return YES;
}

- (void)loadGameBackground {
    // Add the view controller's view to the window and display.
    window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
    CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
                                         pixelFormat: kEAGLColorFormatRGBA8
                                         depthFormat: GL_DEPTH24_STENCIL8_OES
                                  preserveBackbuffer: NO
                                          sharegroup: nil
                                       multiSampling: NO
                                     numberOfSamples: 0 ];
    
    [eaglView setMultipleTouchEnabled:YES];
    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
    // Use RootViewController manage CCEAGLView
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
    viewController.wantsFullScreenLayout = YES;
    viewController.view = eaglView;
    
    // Set RootViewController to window
    if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    {
        // warning: addSubView doesn't work on iOS6
        [window addSubview: viewController.view];
    }
    else
    {
        // use this method on ios6
        [window setRootViewController:viewController];
    }
    
    [[UIApplication sharedApplication] setStatusBarHidden: YES];
    
    // IMPORTANT: Setting the GLView should be done after creating the RootViewController
    cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
    cocos2d::Director::getInstance()->setOpenGLView(glview);
    
    cocos2d::Application::getInstance()->run();
}

- (void)showSplashScreen {

    splashImageView = [[UIImageView alloc] initWithFrame:[window bounds]];
    UIImage* splashImg = [AppController getLaunchImage];
    splashImageView.image = splashImg;
    [splashImageView setContentMode:UIViewContentModeScaleAspectFit];
    splashImageView.layer.zPosition = MAXFLOAT;
    [window addSubview:splashImageView];
    [window bringSubviewToFront:splashImageView];
    
    [splashImageView release];
}

+ (UIImage *)getLaunchImage
{
    CGSize viewSize = [UIScreen mainScreen].bounds.size;
    
    NSString *viewOrientation = nil;
    if (([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) || ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)) {
        viewOrientation = @"Portrait";
    } else {
        viewOrientation = @"Landscape";
    }
    
    NSString *launchImage = nil;
    
    NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
    for (NSDictionary* dict in imagesDict)
    {
        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
        
        if ([viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
        {
            if ([viewOrientation isEqualToString:@"Landscape"]) {
                // landscape will rotate the image
                if (imageSize.width == viewSize.height && imageSize.height == viewSize.width) {
                    launchImage = dict[@"UILaunchImageName"];
                }
            }
            else {
                if (imageSize.width == viewSize.width && imageSize.height == viewSize.height) {
                    launchImage = dict[@"UILaunchImageName"];
                }
            }
        }
    }
    
    return [UIImage imageNamed:launchImage];
}


- (void)removeSplashView {
    splashImageView.layer.zPosition = 0;
    [splashImageView removeFromSuperview];
    splashImageView = nil;
}

+(void) onLoadFinished {
    [_appController removeSplashView];
    // set pointer to nil after using
    _appController = nil;
}

2赞

这段代码返回的launchImage为空呢?可以帮忙看看么

你需要使用Images.xcassets来存放你的启动图片

如果launchImage我指定为一个固定图片的话,可以显示在最上层,但是原来默认的启动图片还是会先显示出来,原来的和这个launchImage是并存的么,一先一后的关系么?之前尝试过删除启动图片,发现启动图片和进入场景后的分辨率识别有关。

一先一后。
进入appcontroller之后,原来的启动图片就会消失,而这时游戏还没加载起来,也就导致了黑屏。我建议的步骤就是:先把你的启动图片放Images.xcassets中,然后用上面这个函数从中取出当前所用的启动图片,并继续显示出来,直到咱们的场景加载起来后再通知native层撤去这个启动图片。
这部分代码的目的就是取出系统启动app时所使用的那张启动图片。

我的项目是横屏的,我在Images.xcassets添加了启动图片,用的已有的Default-Landscape~ipad,Default@2x,Default-568h@2x,Default-667h@2x,Default-736h@3x这5张,把上面的代码调整了下,如果找到的是portrait的图片就rotate负90度,现在可以根据屏幕的分辨率找到不同的图片了,一先一后同样的图片,没有黑屏了。
还是不清楚前边的闪屏是怎么找到对应的图片的,而且图片还影响进入后的场景的分辨率,没找到引擎的相关代码怎么写的?
感谢您的分享和解答。

请问一下onLoadFinished是在哪里调用的