The cocos2d pop-up and screen-taking solution for iPhone 4S

Source: Internet
Author: User
The cocos2d pop-up and screen-taking solution for iPhone 4S

Complex operations in iPhone 4S, or when the ccsprite moves out of the screen, the screen will appear, and the iPhone 4 is normal.

// Solution A: Disable deep detection.

Ccdirector: shareddirector ()-> setdepthtest (false );

Or

// Solution B: 2D projection

Ccdirector: shareddirector ()-> setprojection (kccdirectorprojection2d );

Select any one. After the modification, please test your entire game again. Setdepthtest may affect some effects, transformations, and actions on the Z axis of the tile map.

In the game, click the Home button to return to the main interface. When the game returns, the game restarts. f finds that the game crash is dropped when the home key is clicked.

The reason is that cocos2d did not test iphone4s multithreading during development,

The solution is as follows:

Modify the delegate Function

  1. -(Void) applicationwillresignactive :( uiapplication *) Application {
  2. [[Ccdirector shareddire] stopanimation];
  3. [[Ccdirector shareddire] pause];
  4. }
  5. -(Void) applicationdidbecomeactive :( uiapplication *) Application {
  6. [[Ccdirector shareddire] stopanimation];
  7. [[Ccdirector shareddire] Resume];
  8. [[Ccdirector shareddire] startanimation];
  9. }

Add two functions

  1. -(Void) applicationwillenterforeground :( uiapplication *) Application
  2. {
  3. [[Ccdirector shareddire] startanimation];
  4. }
  5. -(Void) applicationdidenterbackground :( uiapplication *) Application
  6. {
  7. [[Ccdirector shareddire] stopanimation];
  8. [[Ccdirector shareddire] pause];
  9. }

After the modification is complete, there will be no errors. Press the Home key and the program is in the suspended state, and the switch will come again. The program remains in the status before it is released.

Although the technical implementation of the iPhone's multithreading is not perfect, the results are indeed very good.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.