简体   繁体   English

在游戏iOS上使用Parse.com

[英]Using Parse.com for a game iOS

I'm using the Parse framework to create player account functionality in an iOS game so that data is accessible at any device. 我正在使用Parse框架在iOS游戏中创建玩家帐户功能,以便可以在任何设备上访问数据。 However, I'm not sure what the best approach to 'sync' this data would be in order to minimise the api request count yet make it appear as everything is always synced. 但是,我不确定“同步”此数据的最佳方法是什么,以便最大程度地减少api请求的数量,但仍使它看起来像所有事物都始终同步。 I'm currently refreshing data at startup, coming from background and after each game. 目前,我正在启动时刷新数据,这些数据来自后台以及每个游戏之后。 However, that is already creating a lot of requests! 但是,这已经产生了很多请求! I was thinking of placing a 'sync' button in the menu so that only then data is synced and normally saved only locally but it's the last resort really. 我当时正在考虑在菜单中放置一个“同步”按钮,以便只有那时数据才被同步并且通常只在本地保存,但这实际上是最后的手段。

Game Outline: 游戏概要:

  • The players sign up or login using their account or Facebook details 玩家使用其帐户或Facebook详细信息进行注册或登录
  • Player chooses avatar 玩家选择头像
  • Choice is stored to their account 选择存储到他们的帐户
  • They play a 'game' and eventually they lose 他们玩“游戏”,最终输了
  • The summary screen is shown and points are added, new player level is calculated and stored 显示摘要屏幕并添加点,计算并存储新的玩家等级
  • Player can buy hints and helpers via in app purchase (consumable) 玩家可以通过应用内购买来购买提示和助手(消耗品)
  • The number of hints and helpers is stored to their account 提示和助手的数量存储在他们的帐户中
  • Game is universal so must be in sync with devices 游戏具有通用性,因此必须与设备保持同步

What is the best practice for use of Parse in an online GAME with many players? 在具有许多玩家的在线GAME中使用Parse的最佳实践是什么?

Edit: 编辑:

I solved the problem by creating a NSCoding compliant NSObject that I then archive and save to Parse. 我通过创建兼容NSCoding的NSObject解决了问题,然后将其存档并保存到Parse。 This means all data is saved and loaded at once and I only need to update it at startup and after important events. 这意味着所有数据都可以立即保存和加载,而我只需要在启动时和重要事件后进行更新。

As you wrote best approach will be place an 'sync' button to minimize number of request which will be sent to the Parse, because your game can be interrupted at any by incoming call or something else. 在您编写最佳方法时,将放置一个“同步”按钮以最大程度地减少发送到Parse的请求的数量,因为您的游戏可能会因传入呼叫或其他任何原因而中断。

You can reorganize your database for example : You have two object User and Image user have a one to many relation to image, when you fetches a User data to retrieve image you need fetch all images related to this user, this will produce a lot of request to Parse, another way is storing in Image an objectId of the User object and fetch Images for that User by objectId and not storing any relations to Image in User object, that way will drastically reduce the number of request to Parse 您可以重新组织你的数据库,例如 :你有两个目标User and Image用户有一个一对多的关系,以图像,当你获取用户数据检索,你需要获取有关该用户的所有图像的图像,这样会产生大量的请求来解析,另一种方式是在图像存储的objectId用户对象的与该用户通过获取图像objectId和不存储任何关系到图像的用户对象时,该方法将大大减少的请求的数量来解析

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

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