我如何在 PlayN 项目中执行 I/O 操作?
AssetManager 只有 getSound() 和 getImage() 方法。我找不到任何可以提供读/写其他类型资源(例如二进制文件等)的 Streams 实现。 我应该朝什么方向看?
AssetManager has only getSound() and getImage() methods. I couln't find any Streams realisation of smth that could provide reading/writing other kinds of resources such as binaries and so on.
In what direction should i look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于 PlayN 支持最终编译为 JavaScript 的 HTML5,并且 JavaScript 缺乏任何类型的流或二进制 I/O(至少在更多浏览器中提供 WebGL 驱动的二进制支持之前),因此 PlayN 无法提供任何用于流或二进制数据操作的 API 。
最好的选择是使用 JSON 和预定义的媒体格式(如图像和声音)。
Because PlayN supports HTML5 which ultimately compiles to JavaScript, and because JavaScript lacks any sort of streams or binary I/O (at least until the WebGL motivated binary support becomes available in more browsers), PlayN cannot provide any APIs for streams or binary data manipulation.
Your best bet is to use JSON and predefined media formats (like images and sounds).
除了 getImage 和 getSound 之外,它还有 getText,您可以使用它来读取其他类型的资源(包括 JSON 文件)。如果您不致力于流和二进制数据,GetText 可能对您有用。
就编写而言,存储 API 存在用于简单的键/值对,这对于保存游戏来说足够了。我不确定这是否是你的想法。
In addition to getImage and getSound, it also has getText, which you can use to read other kinds of resources (including JSON files). If you're not committed to streams and binary data, GetText may be useful to you.
As far as writing, the Storage API exists for simple key/value pairs, which is sufficient for savegames. I'm not sure if that's what you had in mind.