@@ -111,6 +111,8 @@ var ParseTileLayers = function (json, insertNull)
111
111
var gidInfo ;
112
112
var tile ;
113
113
var blankTile ;
114
+ var triangleHeight ;
115
+ var triangleWidth ;
114
116
115
117
var output = [ ] ;
116
118
var x = 0 ;
@@ -140,6 +142,19 @@ var ParseTileLayers = function (json, insertNull)
140
142
layerData . hexSideLength = json . hexsidelength ;
141
143
layerData . staggerAxis = json . staggeraxis ;
142
144
layerData . staggerIndex = json . staggerindex ;
145
+
146
+ if ( layerData . staggerAxis === 'y' )
147
+ {
148
+ triangleHeight = ( layerData . tileHeight - layerData . hexSideLength ) / 2 ;
149
+ layerData . widthInPixels = layerData . tileWidth * ( layerData . width + 0.5 ) ;
150
+ layerData . heightInPixels = layerData . height * ( layerData . hexSideLength + triangleHeight ) + triangleHeight ;
151
+ }
152
+ else
153
+ {
154
+ triangleWidth = ( layerData . tileWidth - layerData . hexSideLength ) / 2 ;
155
+ layerData . widthInPixels = layerData . width * ( layerData . hexSideLength + triangleWidth ) + triangleWidth ;
156
+ layerData . heightInPixels = layerData . tileHeight * ( layerData . height + 0.5 ) ;
157
+ }
143
158
}
144
159
145
160
for ( var c = 0 ; c < curl . height ; c ++ )
@@ -221,6 +236,19 @@ var ParseTileLayers = function (json, insertNull)
221
236
layerData . hexSideLength = json . hexsidelength ;
222
237
layerData . staggerAxis = json . staggeraxis ;
223
238
layerData . staggerIndex = json . staggerindex ;
239
+
240
+ if ( layerData . staggerAxis === 'y' )
241
+ {
242
+ triangleHeight = ( layerData . tileHeight - layerData . hexSideLength ) / 2 ;
243
+ layerData . widthInPixels = layerData . tileWidth * ( layerData . width + 0.5 ) ;
244
+ layerData . heightInPixels = layerData . height * ( layerData . hexSideLength + triangleHeight ) + triangleHeight ;
245
+ }
246
+ else
247
+ {
248
+ triangleWidth = ( layerData . tileWidth - layerData . hexSideLength ) / 2 ;
249
+ layerData . widthInPixels = layerData . width * ( layerData . hexSideLength + triangleWidth ) + triangleWidth ;
250
+ layerData . heightInPixels = layerData . tileHeight * ( layerData . height + 0.5 ) ;
251
+ }
224
252
}
225
253
var row = [ ] ;
226
254
0 commit comments