简体   繁体   English

iPhone游戏暂停和恢复,值得实现吗?

[英]iPhone Game pause and resume, is it worth implementing?

Allow me to describe my situation:请允许我描述一下我的情况:

I want to develop a game, that is round-base, and pay-to-play.我想开发一款游戏,即回合制和付费游戏。 That means you pay one coin, for one round of game, like Pinball etc.这意味着您为一轮游戏支付一枚硬币,例如弹球等。

The problem is, when there is interruption, ideally the game should pause, and resume whenever the user desires.问题是,当出现中断时,理想情况下游戏应该暂停,并在用户需要时恢复。 Implementing that seems to be a challenge.实施这似乎是一个挑战。 Say my game was put into background, I would save the game state in ApplicationDidEnterBackground.假设我的游戏已进入后台,我会将游戏 state 保存在 ApplicationDidEnterBackground 中。 However the game may or may not get terminated while in the background.但是,游戏可能会或可能不会在后台终止。 So the next launch could be a "fresh start", or, a "resume from last saved state".因此,下一次启动可能是“重新开始”,或者是“从上次保存的状态恢复”。

If the app is left in the background long enough, say 1 week, its almost certain that other apps fighting for memory will cause the game to be terminated at some point.如果该应用程序在后台停留的时间足够长,例如 1 周,那么几乎可以肯定其他争夺 memory 的应用程序将导致游戏在某个时候终止。 When the user starts my app again, they would be playing from a new round, meaning that the previously unfinished game, is gone.当用户再次启动我的应用程序时,他们将开始新一轮游戏,这意味着之前未完成的游戏已经消失。

From a customer point of view, this is unfair.从客户的角度来看,这是不公平的。

What I can think of is, to implement it so that whenever my app is brought to the foreground, I would go check if there was a saved game.我能想到的是,实现它以便每当我的应用程序被带到前台时,我会 go 检查是否有保存的游戏。 If there was, I shall resume it instead.如果有,我将改为恢复它。 This poses a security issue:这带来了一个安全问题:

Saved game, either in most primitive plist format or other formats, are persisted, and poses security problems.保存的游戏,无论是最原始的 plist 格式还是其他格式,都会被持久化,并带来安全问题。 (What if players edit the game state and score 10 million points as top score... etc) (如果玩家编辑游戏 state 并获得 1000 万分作为最高分...等)

Are there any recommended ways to tackle these problems?有没有推荐的方法来解决这些问题?

I see some Apps simply give up on saving the game, and a new round will be started on resume.我看到有的App直接放弃了保存游戏,恢复后会开始新的一轮。 Those are not paid to play games, otherwise I can imagine users getting very angry.那些不是为了玩游戏而付费的,否则我可以想象用户会非常生气。

I have seen some Apps that saves the game state for a while, but when it got terminated, when next launched, it will start a fresh round.我见过一些应用程序保存了游戏 state 一段时间,但是当它被终止时,下次启动时,它将开始新一轮。 Which seems just as unacceptable in the case where players actually paid money for the round.在玩家实际为该回合付费的情况下,这似乎是不可接受的。

And when taken into account the possibility of crashes, I cannot come up with a good solution that ensure paying customer will get to play a full round of game.考虑到崩溃的可能性,我无法想出一个好的解决方案来确保付费客户能够玩一整轮游戏。 It would really help me if someone with relevant experience could share their thoughts, and how they make their decisions.如果有相关经验的人可以分享他们的想法,以及他们如何做出决定,那真的会对我有所帮助。

Why not tie the round finishing to the payment?为什么不将回合结束与付款联系起来? If the round doesn't finish, no payment is taken.如果回合未结束,则不收取任何费用。 If the user's credits are insufficient at the time the round finishes, you could give them the option to purchase more credits immediately (via in-app purchase) to finish the current round.如果该回合结束时用户的积分不足,您可以让他们选择立即购买更多积分(通过应用内购买)以完成当前回合。

That simplifies your task as a developer, and also provides a way to prompt the user for additional payment in a non-obnoxious way.这简化了您作为开发人员的任务,并且还提供了一种以不令人讨厌的方式提示用户进行额外付款的方法。

Here 'sa great tutorial on using NSCoding to save game states. 是关于使用 NSCoding 保存游戏状态的精彩教程。 It won't have any problem with the player going in a editing the file, as it is done in NSCoding.播放器在编辑文件时不会有任何问题,就像在 NSCoding 中所做的那样。 If a user REALLY wants to figure out how to un-encode the file and change the contents, which is crazy, you could do some kind of encryption on the data BEFORE you write it to file, so there would be no way the user could change it.如果用户真的想弄清楚如何取消编码文件并更改内容,这很疯狂,您可以在将数据写入文件之前对数据进行某种加密,这样用户就无法更改。 Hope that helps!希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM