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
- -(Void) applicationwillresignactive :( uiapplication *) Application {
- [[Ccdirector shareddire] stopanimation];
- [[Ccdirector shareddire] pause];
- }
- -(Void) applicationdidbecomeactive :( uiapplication *) Application {
- [[Ccdirector shareddire] stopanimation];
- [[Ccdirector shareddire] Resume];
- [[Ccdirector shareddire] startanimation];
- }
Add two functions
- -(Void) applicationwillenterforeground :( uiapplication *) Application
- {
- [[Ccdirector shareddire] startanimation];
- }
- -(Void) applicationdidenterbackground :( uiapplication *) Application
- {
- [[Ccdirector shareddire] stopanimation];
- [[Ccdirector shareddire] pause];
- }
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.