file_bin_open

此函数将打开具有指定名称的二进制文件。该模式指示可以对文件执行的操作:

当该文件不存在时,将创建该文件,并且该函数返回必须在其他函数中使用的文件的 id。您可以同时打开多个文件 (最大 32 个) ,但是不要忘记在完成后关闭它们。

In the case of an error, the function will return -1. However, in some cases where the file could not be loaded (like an invalid filename being passed), the function may still return a file ID, in which case the return value of the file closing function will be false.

警告 由于 GameMaker 处于沙盒状态,这可能无法按您的预期工作!请参阅有关 文件系统 的部分了解更多信息。

注意 当目标模块是 HTML5 时,这些函数 不起作用

 

语法:

file_bin_open(fname, mode);

参数类型描述
fnameString要从中读取的文件的名称。
modeReal可以对文件执行哪些操作的指示符。

 

返回:

Binary File ID or -1

 

例子:

file = file_bin_open("myfile.bin", 2);

这将从游戏的同一目录中打开一个文件,并将其索引分配给变量 "file".