zoukankan      html  css  js  c++  java
  • iphone4s中cocos2d出现闪屏,花屏的解决方案

    iphone4s中cocos2d出现闪屏,花屏的解决方案

    iphone4s中运行复杂的动作,或者ccsprite运动出屏幕的时候会出现花屏的情况,在iphone4中正常。

    // 解决方法 A:关闭深度检测

    CCDirector::sharedDirector()->setDepthTest(false);

    或者

    // 解决方法B:使用2D投射

    CCDirector::sharedDirector()->setProjection(kCCDirectorProjection2D);

    选任意一个都行。修改之后,请重新测试一下你的整个游戏。setDepthTest 可能会影响到一些效果,转换以及瓦片地图z轴上的行为。





    游戏中,点击home键按钮回到主界面,当再回到游戏时,游戏重新启动,后面f发现当点击home键时游戏crash掉。

    原因是cocos2d开发时候没有测试iphone4s多线程的情况,

    解决方案如下

    修改delegate的函数

    1. - (void)applicationWillResignActive:(UIApplication *)application {  
    2.         [[CCDirector sharedDirector] stopAnimation];  
    3.     [[CCDirector sharedDirector] pause];  
    4. }  
    5.   
    6. - (void)applicationDidBecomeActive:(UIApplication *)application {  
    7.         [[CCDirector sharedDirector] stopAnimation];   
    8.     [[CCDirector sharedDirector] resume];  
    9.     [[CCDirector sharedDirector] startAnimation];  
    10. }  
    并增加两个函数

    1. - (void)applicationWillEnterForeground:(UIApplication *)application  
    2. {  
    3.     [[CCDirector sharedDirector] startAnimation];  
    4. }  
    5.   
    6. - (void)applicationDidEnterBackground:(UIApplication *)application  
    7. {  
    8.         [[CCDirector sharedDirector] stopAnimation];  
    9.     [[CCDirector sharedDirector] pause];  
    10. }  

     这样修改完成后,就不会出错了,按home键程序处于刮起挂起状态,再切会来是,程序保持在推出之前的状态

    iphone的多线程虽说技术上实现的不是很完美,但效果确实很不错





  • 相关阅读:
    【题解】CF#983 E-NN country
    【题解】CF#403 D-Beautiful Pairs of Numbers
    【题解】CF#285 E-Positions in Permutations
    【题解】FJOI2015火星商店问题
    【题解】Atcoder AGC#01 E-BBQ Hard
    【题解】Atcoder AGC#03 E-Sequential operations on Sequence
    【题解】CF#280 C-Game on Tree
    【题解】CF#833 B-The Bakery
    [BZOJ3600] 没有人的算术 [重量平衡树+权值线段树]
    [bzoj3514][CodeChef GERALD07] Chef ans Graph Queries [LCT+主席树]
  • 原文地址:https://www.cnblogs.com/hainange/p/6153233.html
Copyright © 2011-2022 走看看