我如何在 PlayN 项目中执行 I/O 操作?

发布于 2024-12-14 10:53:13 字数 103 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

屋顶上的小猫咪 2024-12-21 10:53:14

由于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文