此函数移动缓冲区的查找位置,将其设置为相对于开始、结束或当前查找位置 (读取或写入数据时最后使用的位置)。
查找位置是距 写入 新值和 读取 值的缓冲区开头的偏移量 (以字节为单位)。当您读取或写入缓冲区时,它也会自动移动。
接受以下常量作为"base"参数来寻求:
缓冲区寻道常量 | |
---|---|
常量 | 描述 |
buffer_seek_start | The start of the buffer |
buffer_seek_relative | A position relative to the current read/write position |
buffer_seek_end | The end of the buffer |
buffer_seek(buffer, base, offset);
参数 | 类型 | 描述 |
---|---|---|
buffer | Buffer | The buffer to use. |
base | Real | 寻求的基础位置。 |
offset | Real | 数据偏移值。 |
Real (the new seek position)
buffer_seek(buff, buffer_seek_start, 0);
buffer_write(buff, buffer_s16, 0);
buffer_write(buff, buffer_s16, x);
buffer_write(buff, buffer_s16, y);
上面的代码找到存储在变量 buff 中的缓冲区的开头,然后向其中写入一系列带符号的 16 位整数值。