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 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

[Collision]
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

我的屏幕上还有一个正方形,用于填充鼠标单击的图块。我遇到的问题是我希望能够通过根据我在地图上单击的位置更改它的值来编辑 map.txt 文件。我需要知道是否有一种方法可以访问映射文件中的某个值,例如数组。因此,例如获取 Collision[5][8] 或 Details[7][17] 等。谢谢!

http://screencast.com/t/gqH18wgW(这里显示点击查找位置)

4

1 回答 1

5

虽然您可以将位置存储在每个单元格的文件中并覆盖单个单元格,但这仅在旧字符串和新字符串长度相同时才有效。

一种更灵活且非常直接的方法是:

于 2013-01-17T17:05:38.957 回答