【发布时间】:2017-12-18 20:02:45
【问题描述】:
我将平铺制作的等距地图导入 Corona SDK,现在正尝试覆盖网格层。我已经对等距网格进行了大量阅读,但似乎它们都引用了高度为宽度一半的图块集。 (例如 128x64 像素)。我正在使用一个需要网格为 256x149px 的图块集,我认为我必须编辑网格生成函数以适应更改。任何帮助将不胜感激!
问题截图(使用原始向量):
Original Vectors: https://image.ibb.co/emXpQR/Screen_Shot_2017_12_18_at_1_35_19_PM.png
Edited Vectors (the ones commented out in code): https://image.ibb.co/ikxOkR/Screen_Shot_2017_12_18_at_1_35_54_PM.png
网格生成代码:
function drawGrid()
for row = 0, 16 do
local gridRow = {}
for col = 0, 9 do
-- draw a diamond shaped tile
local vertices = { 0,-16, -64,16, 0,48, 64,16 }
-- MY EDITED VERTICES { 0,-37.25, -128,37.25, 0,111.75, 128,37.25 }
local tile = display.newPolygon(group, 0, 0, vertices )
-- outline the tile and make it transparent
tile.strokeWidth = 1
tile:setStrokeColor( 0, 1, 1 )
tile.alpha = .4
local tileWidth = 256
local tileHeight = 149
-- set the tile's x and y coordinates
local x = col * tileHeight
local y = row * tileHeight
tile.x = (x - y)
tile.y = ((tileHeight/2) + ((x + y)/2))
-- make a tile walkable
gridRow[col] = 0
end
-- add gridRow table to the map table
j_map[row] = gridRow
end
end
正如您在屏幕截图中看到的那样,图块有点偏离地图的一侧。如果有人知道如何修复它或需要有关信息的更多信息,请告诉我!
【问题讨论】:
-
你在 Corona SDK 中使用什么来渲染等距地图?
标签: lua grid coronasdk isometric tiled