恢复游戏 cocos2d
问题描述
我使用下面的代码来处理我的游戏中的暂停和恢复按钮
I used he code below to handle pause and resume buttons in my game
暂停:
继续:
问题是如果使用点击暂停然后进入后台(点击主页按钮)模式当他返回时,游戏自动恢复,暂停菜单仍然存在
The problem is if the used click pause then enterBackground (click Home button) mode when he returns, the game automatically resume and the pause menu still exist
任何想法都会很棒
更新:
AppDelegate 代码:
the AppDelegate code:
谢谢
推荐答案
您应该向您的应用程序委托添加一个属性,该属性将跟踪暂停是由用户点击暂停按钮还是自动引起的.
You should add a property to your app delegate that will keep track if pause was caused by user tapping pause button or automatically.
在 YourAppDelegate.h 中:
Inside YourAppDelegate.h:
在 YourAppDelegate.h 中:
And inside YourAppDelegate.h:
然后在场景的 pause 方法中,添加:
Then inside your scene's pause method, add:
在场景的 resume 方法中,添加:
And inside your scene's resume method, add:
现在您可以编辑您的应用委托的 -applicationWillResignActive: 方法以仅在 userPaused 未设置为 YES 时恢复.
Now you can edit your app delegate's -applicationWillResignActive: method to only resume if userPaused is not set to YES.
这篇关于恢复游戏 cocos2d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!