IOS:如何防止重新启用idleTimer时屏幕立即变灰
我正在开发一款主要使用加速计输入的 iOS 游戏。以前的程序员在启动时设置idleTimerDisabled = YES并保持这种状态。我最近做了一个更改,空闲计时器仅在游戏过程中被禁用,并在关卡结束时重新启用。
问题是,如果关卡的播放时间比用户的idleTimer设置长,那么当我设置idleTimerDisabled=NO时,屏幕就会变灰。有没有办法在重新启用时重置计时器,以便在idleTimer使屏幕变暗之前发生完整的时间增量?
I'm working on an iOS game that primarily uses accelerometer input. Previous programmers set idleTimerDisabled=YES on startup and left it that way. I recently made a change such that the idle timer is only disabled during gameplay, and is re-enabled when a level ends.
The problem is, if the play time of the level is longer than the user's idleTimer setting, the screen will grey out the moment I set idleTimerDisabled=NO. Is there a way to reset the timer upon re-enabling so that the full time increment will occur before the idleTimer dims the screen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用类似的方法禁用计时器上的空闲计时器。
或者,这是一种更现代、更简单的方法:
Disable the idle timer on a timer, using something like this.
Alternately, this is a more modern and simple approach: