<legend id='zcjwk'><style id='zcjwk'><dir id='zcjwk'><q id='zcjwk'></q></dir></style></legend>

  • <tfoot id='zcjwk'></tfoot>
  • <small id='zcjwk'></small><noframes id='zcjwk'>

      <bdo id='zcjwk'></bdo><ul id='zcjwk'></ul>

      <i id='zcjwk'><tr id='zcjwk'><dt id='zcjwk'><q id='zcjwk'><span id='zcjwk'><b id='zcjwk'><form id='zcjwk'><ins id='zcjwk'></ins><ul id='zcjwk'></ul><sub id='zcjwk'></sub></form><legend id='zcjwk'></legend><bdo id='zcjwk'><pre id='zcjwk'><center id='zcjwk'></center></pre></bdo></b><th id='zcjwk'></th></span></q></dt></tr></i><div id='zcjwk'><tfoot id='zcjwk'></tfoot><dl id='zcjwk'><fieldset id='zcjwk'></fieldset></dl></div>

      1. 正确的 cocos2d 场景重启?

        时间:2024-08-12
      2. <legend id='iy4Yj'><style id='iy4Yj'><dir id='iy4Yj'><q id='iy4Yj'></q></dir></style></legend>
          <bdo id='iy4Yj'></bdo><ul id='iy4Yj'></ul>

          <small id='iy4Yj'></small><noframes id='iy4Yj'>

              • <i id='iy4Yj'><tr id='iy4Yj'><dt id='iy4Yj'><q id='iy4Yj'><span id='iy4Yj'><b id='iy4Yj'><form id='iy4Yj'><ins id='iy4Yj'></ins><ul id='iy4Yj'></ul><sub id='iy4Yj'></sub></form><legend id='iy4Yj'></legend><bdo id='iy4Yj'><pre id='iy4Yj'><center id='iy4Yj'></center></pre></bdo></b><th id='iy4Yj'></th></span></q></dt></tr></i><div id='iy4Yj'><tfoot id='iy4Yj'></tfoot><dl id='iy4Yj'><fieldset id='iy4Yj'></fieldset></dl></div>

                  <tbody id='iy4Yj'></tbody>

                  <tfoot id='iy4Yj'></tfoot>
                • 本文介绍了正确的 cocos2d 场景重启?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  cocos2d场景在上一个之后如何重新启动并清理内存?

                  [director replaceScene:s] 正在显示粉色屏幕.无法让它工作.

                  [director replaceScene:s] is displaying pink screen. Can't get it to work.

                  我所做的解决方法如下,但是在关闭场景后,应用程序运行速度非常慢并且对触摸的反应很慢.MainViewController.m:

                  The work-around I made is below, however after closing scene this way app runs very slow and slowly reacts to touch. MainViewController.m:

                  - (IBAction)startScene { 
                  
                  [CCTexture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
                  
                  if ([director runningScene]) {
                      [director end];
                      works = NO;
                  }
                  if (!works) {
                      EAGLView *glview = [EAGLView viewWithFrame:CGRectMake(0,0, 768, 1024)]; 
                      [self.view addSubview:glview];
                      [director setOpenGLView:glview];
                      CCLayer *layer = [PlayLayer node];
                      CCScene *s = [CCScene node];
                      [s addChild: layer];
                      [director runWithScene:s];
                  }
                  

                  }

                  PlayLayer.m 我从场景返回查看使用:

                  Inside PlayLayer.m I go back from scene to view using:

                  CCDirector *d = [CCDirector sharedDirector];
                  EAGLView *v = [d openGLView];
                  [v removeFromSuperview];
                  

                  应用程序正在显示图像(1280x960x32,滚动视图内的图像视图),当用户按下按钮时,他可以启动 cocos2d 场景.然后,用户可以从场景返回查看 (.xib) 并继续浏览图像,直到找到新的开始场景.

                  Application is displaying images (1280x960x32, imageview inside scrollview) and when user presses the button he can start cocos2d scene. User can then leave from scene back to view (.xib) and continue browsing through images till he finds a new one to start scene with.

                  我相信这不是离开场景的好方法,但我尝试的所有其他方法都会导致应用程序崩溃,或者我第二次开始场景时总是出现这个粉红色的屏幕.怎么重启?

                  I believe this is not a good way to leave scene but everything else I tried is causing app to crash or I keep getting this pink screen 2nd time I start scene. How do I restart it ?

                  推荐答案

                  好的,找到了一个从内部关闭场景并且效果很好的解决方案.

                  Ok, found a solution that closes the scene from inside and works well.

                  在开始场景时,我在视图控制器中添加通知观察者:

                  While starting scene I add the notification observer in my viewcontroller:

                  (...)
                  [director runWithScene:s];
                  [[NSNotificationCenter defaultCenter] addObserver:self 
                        selector:@selector(mySceneEnd:) name:@"scene_ended" object:nil];
                  

                  连接到:

                  - (void) mySceneEnd:(NSNotification *)notif {   
                      if ([director runningScene])
                          [director end];
                      [[NSNotificationCenter defaultCenter] removeObserver:self];
                  }
                  

                  然后在场景结束方法中,我将通知发送到我的视图控制器:

                  Then in the scene ending method I'm sending the notification to my viewcontroller:

                  EAGLView *v = [[CCDirector sharedDirector] openGLView];
                  [v removeFromSuperview];
                  [[NSNotificationCenter defaultCenter] postNotificationName:@"scene_ended" 
                       object:nil userInfo:nil];
                  

                  效果非常好,关闭场景后应用程序运行速度很快,但这是一个老问题/答案,现在肯定有更好的方法.

                  Works really nice, app runs fast after closing scene, but it's an old question/answer and there is surely a better way to do it now.

                  这篇关于正确的 cocos2d 场景重启?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:[ios.cocos2d+box2d]如何禁用自动旋转? 下一篇:如何将 32 位 PNG 转换为 RGB565?

                  相关文章

                  1. <tfoot id='LM5as'></tfoot>
                    <i id='LM5as'><tr id='LM5as'><dt id='LM5as'><q id='LM5as'><span id='LM5as'><b id='LM5as'><form id='LM5as'><ins id='LM5as'></ins><ul id='LM5as'></ul><sub id='LM5as'></sub></form><legend id='LM5as'></legend><bdo id='LM5as'><pre id='LM5as'><center id='LM5as'></center></pre></bdo></b><th id='LM5as'></th></span></q></dt></tr></i><div id='LM5as'><tfoot id='LM5as'></tfoot><dl id='LM5as'><fieldset id='LM5as'></fieldset></dl></div>

                  2. <legend id='LM5as'><style id='LM5as'><dir id='LM5as'><q id='LM5as'></q></dir></style></legend>

                        <bdo id='LM5as'></bdo><ul id='LM5as'></ul>

                      <small id='LM5as'></small><noframes id='LM5as'>