| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2013-10-13 |
| 在线时间 | 142 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 142 小时
- 注册时间
- 2013-4-13
- 回帖
- 82
|
楼主 |
发表于 2013-6-20 17:17:04
|
显示全部楼层
本帖最后由 爆发的妞 于 2013-6-21 17:41 编辑
需要用到数据库中的图块的数据,直接解析生成的文件, 貌似没有那么容易,
结构不太明白,还需要深入学习。所以就简单的在工程中输出了。
需要用到的同学,可以拿去
代码如下:
[pre lang="ruby" line="1"] #输出Tilesets
#创建一个可写文件流
fh = File.new(sprintf("Data/Tilesets.rx"), "w")
#输出地图数据
size = $data_tilesets.size - 1
for i in 1..size
tileset = $data_tilesets
tileset_name = tileset.tileset_name
autotile_names = tileset.autotile_names
panorama_name = tileset.panorama_name
panorama_hue = tileset.panorama_hue
fog_name = tileset.fog_name
fog_hue = tileset.fog_hue
fog_opacity = tileset.fog_opacity
fog_blend_type = tileset.fog_blend_type
fog_zoom = tileset.fog_zoom
fog_sx = tileset.fog_sx
fog_sy = tileset.fog_sy
battleback_name = tileset.battleback_name
passages = tileset.passages
priorities = tileset.priorities
terrain_tags = tileset.terrain_tags
fh.puts i
fh.puts 'tileset_name %s.png'% [tileset_name]
fh.print 'autotile_names '
for i in 0..autotile_names.size
if autotile_names.nil?
fh.print ','
else
fh.print '%s.png,'% [autotile_names]
end
end
fh.puts ''
passages_size = passages.xsize
fh.print 'passages '
for i in 0..passages_size
fh.print '%s,'% [passages]
end
fh.puts ''
priorities_size = priorities.xsize
fh.print 'priorities '
for i in 0..priorities_size
if i==priorities_size
fh.print '%s'% [priorities]
elsif i==0
fh.print '%s,'% [5]
else
fh.print '%s,'% [priorities]
end
end
fh.puts ''
end
fh.close #关闭文件流[/pre]
下面的代码是对应地图图块的数据输出,
代码如下:
[pre lang="ruby" line="1"] #创建一个可写文件流
fh = File.new(sprintf("Data/Map%03d.rx", @map_id), "w")
#输出地图数据
for i in 0..2
xsize = @map.data.xsize
#print xsize
ysize = @map.data.ysize
#print ysize
fh.puts '[w = %s][h = %s]'% [xsize,ysize]
for line in 0...ysize
for col in 0...xsize
tile_id = @map.data[col, line, i]
if tile_id == nil
#fh.puts "[%s][%s][%s]=%s" % [col, line,i,'空'] #写入数据
#print "[%s][%s][0]=%s" % [col, line,'空']
fh.print "%s," % ['空']
else
#fh.puts "[%s][%s][%s]=%s" % [col, line,i,tile_id] #写入数据
#print "[%s][%s][0]=%s" % [col, line,tile_id]
if col==xsize-1
fh.print "%s" % [tile_id]
else
fh.print "%s," % [tile_id]
end
end
end
fh.puts ''
end
fh.puts ''
end
fh.close #关闭文件流[/pre]
后续还会解析其他的数据,感兴趣的可以,共同研究 |
|