2017-12-18 21 views
0

コロナSDKにタイル張りされたアイソメトリックマップをインポートし、グリッドレイヤをオーバーレイしようとしています。私はアイソメトリックグリッドを多読しましたが、それらはすべて、高さが幅の半分であるタイルセットを参照しているようです。 (例:128x64px)。私は256x149pxのグリッドを必要とするタイルセットを使用していますが、私はその変更に対応するためにグリッド生成関数を編集する必要があると思います。どんな助けでも大歓迎です! (オリジナルのベクトルを用いた)問題のコロナSDKのタイルセットのアイソメトリックグリッドの生成

スクリーンショット:

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 

地図の横にあるようなもの。誰かがそれを修正する方法を知っているか、情報に関するより多くの情報が必要な場合は、私に知らせてください!

+0

コロナSDKのアイソメトリックマップのレンダリングにはどうしますか? – ldurniat

答えて

0

てみてくださいコード:

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 
     local 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 

     tile.x = -(row - col) * tileWidth * 0.5 
     tile.y = (row + col) * tileHeight * 0.5 

     -- make a tile walkable 
     gridRow[col] = 0 
     end 
     -- add gridRow table to the map table 
     --j_map[row] = gridRow 
    end 

私はIsometric Tiles Mathからタイルのxy位置のための式を取得します。幸運:)

+0

ありがとうございます!私はIsometric Tiles Mathページを見て、バグは私が間違っていることを理解できませんでした。あなたのソリューションはうまくいった! – Co1eK

関連する問題