将两个文件分组为一个自定义文件类型(Grouping two files into one custom file

系统教程 行业动态 更新时间:2024-06-14 16:59:17
将两个文件分组为一个自定义文件类型(Grouping two files into one custom file-type)

我目前正致力于iOS的简单塔防游戏(使用objective-c),其中包含几个地图/关卡。 但是,就像现在一样,每个映射都包含一个图像文件和一个包含信息的.plist文件。 我的问题是:有什么办法可以创建一个包含图像和plist信息的自定义文件类型(例如,* .map)?

如果可以,我该如何实现?

提前致谢!

I am currently working on a simple tower defense game for iOS (using objective-c), which contains several maps/levels. However, as it is now, each map consists of an image file and a .plist file with information. My question is: is there any way I could create a custom file type (for example, *.map) that contains both the image and the information from the plist?

If this is possible, how do I implement this?

Thanks in advance!

最满意答案

你有几个不错的选择:

最简单的解决方案是将相关文件分组到子文件夹中:您可以拥有一个xyz子文件夹,而不是拥有xyz子文件夹,并从中引用文件。 您不需要为此使用任何其他库,并且您可以对所有图像文件和所有级别文件使用相同的名称,因为它们将位于单独的文件夹中。 您可以使用要组合的文件制作zip存档,并在使用前将其解压缩。 以下是引用库的答案的链接。 您可以使用tar格式 - 这是一个引用支持它的库的答案列表。 您可以在OS-X上使用tar实用程序在工作站上使用plist对图像进行分组。 最后,您可以定义自己的格式:在前四个字节中存储第一个文件的长度,然后存储第一个文件的内容,然后存储第二个文件的内容。 您需要编写一个实用程序,将两个文件合并为一个。 这听起来是最难实施的选择。

You have several good choices for that:

The simplest solution would be grouping the related files in subfolders: rather than having xyz.map file, you could have an xyz sub-folder, and reference the files out of it. You would not need to use any additional libraries for this, and you would be able to use the same name for all your image files and all your level files, because they would be in separate folders. You can make a zip archive with the files that you would like to combine, and unzip it before use. Here is a link to an answer referencing a library to do it. You can use a tar format - here is a list to an answer referencing a library that supports it. You would be able to use tar utility on OS-X to group images with plists on your workstation. Finally, you can define a format of your own: store the length of the first file in the first four bytes, then store the content of the first file, and then the second. You would need to write a utility for combining the two files into one. This sounds like the hardest choice to implement.

更多推荐

本文发布于:2023-04-16 14:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/875b4c10844697199bef087fb4533301.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   文件类型   两个   文件   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!