File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ class GodotTilemapExporter {
181
181
/**
182
182
* Tileset should expose columns ... but didn't at the moment so we
183
183
* calculate them base on the image width and tileWidth
184
- * return {String }
184
+ * return {number }
185
185
**/
186
186
getTilesetColumns ( tileset ) {
187
187
// noinspection JSUnresolvedVariable
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ class GodotTilesetExporter {
42
42
43
43
let tile = tiles [ index ] ;
44
44
45
+ const tilesetColumns = this . getTilesetColumns ( ) ;
46
+ if ( ( autotileCoordinates . x + 1 ) > tilesetColumns ) {
47
+ autotileCoordinates . x = 0 ;
48
+ autotileCoordinates . y += 1 ;
49
+ }
50
+
45
51
// noinspection JSUnresolvedVariable
46
52
if ( tile . objectGroup !== null ) {
47
53
@@ -64,9 +70,6 @@ class GodotTilesetExporter {
64
70
}
65
71
66
72
autotileCoordinates . x += 1 ;
67
- if ( ( index ) < this . tileset . columns ) {
68
- autotileCoordinates . y += 1 ;
69
- }
70
73
71
74
}
72
75
@@ -96,6 +99,16 @@ class GodotTilesetExporter {
96
99
) ;
97
100
}
98
101
102
+ /**
103
+ * Tileset should expose columns ... but didn't at the moment so we
104
+ * calculate them base on the image width and tileWidth
105
+ * return {number}
106
+ **/
107
+ getTilesetColumns ( ) {
108
+ // noinspection JSUnresolvedVariable
109
+ return Math . floor ( this . tileset . imageWidth / this . tileset . tileWidth ) ;
110
+ }
111
+
99
112
getTilesetTemplate ( ) {
100
113
// noinspection JSUnresolvedVariable
101
114
return `[gd_resource type="TileSet" load_steps=3 format=2]
You can’t perform that action at this time.
0 commit comments