2017-12-18 14 views
0

Ich importierte eine isometrische Map, die in Corona SDK erstellt wurde und versuche nun eine Rasterebene zu überlagern. Ich habe viel in isometrischen Gittern gelesen, aber es scheint, dass sie alle auf Ziegelsets verweisen, deren Höhe die Hälfte der Breite beträgt. (z. B. 128x64px). Ich verwende ein Tileset, das das Raster 256x149px erfordert, und ich denke, dass ich die Rastergenerierungsfunktion bearbeiten muss, um die Änderung anzupassen. Jede Hilfe würde sehr geschätzt werden!Isometrisches Gitter für Tileset in Corona SDK generieren

Screenshot der Ausgabe (mit Original-Vektoren):

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

Grid-Generation-Code:

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 

Wie Sie die Fliesen in den Screenshots sehen können Art von veer von der Seite der Karte. Wenn jemand weiß, wie man es reparieren kann oder mehr Informationen benötigt, lass es mich wissen!

+0

Was verwenden Sie zum Rendern einer isometrischen Karte in Corona SDK? – ldurniat

Antwort

0

Try Code:

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 

ich Formel für x und y Position der Fliese aus Isometric Tiles Math. Viel Glück :)

+0

Vielen Dank! Ich schaute auch auf die Isometric Tiles Mathe Seite Bug konnte nicht herausfinden, was ich falsch gemacht haha. Ihre Lösung hat funktioniert! – Co1eK