How to implement pause/resume in cocos2d game?(cocos2d游戏中如何实现暂停/恢复?)
问题描述
我的问题是寻找 cocos2d 游戏期间暂停/恢复状态(包括所有需要保存的数据信息)的设计解决方案.
My question is to look for design solution for pause/resume states (including all data info, which need save ) during cocos2d game.
包括但不限于以下情况:
Including following cases, but not limited:
1).用户选择退出,然后弹出一个对话框供用户选择直接退出"、暂停";
1). User choose quit, then pop out one dialog for user to choose " quit directly", " pause " ;
2).有人呼入,弹出对话框供用户选择退出"或暂停"游戏.
2). Someone call in , pop out dialog for user to choose "quit " or " pause " game.
如果选择暂停",应该保存所有值得保存的内容.就像 PC 游戏一样.
If choose "pause", everything which deserve saving, should be saved. Just like PC games do.
我知道导演提供了暂停"、恢复",这个任务可以吗?
I know Director provides "pause" , "resume " , is that okay for this task ?
感谢任何线索或评论.
欢迎通过电子邮件进一步讨论:apple.dev.sh@gmail.com
Welcome for further discussing via email : apple.dev.sh@gmail.com
推荐答案
这是一个很好的例子:
暂停:
- (void) applicationDidEnterBackground:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}
恢复时:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[[CCDirector sharedDirector] stopAnimation]; // call this to make sure you don't start a second display link!
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation];
}
这篇关于cocos2d游戏中如何实现暂停/恢复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cocos2d游戏中如何实现暂停/恢复?
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01