Skip to content

Commit 039932c

Browse files
authored
Merge pull request #31 from eleniums/add-opacity
Add support for opacity, offset, and visibility
2 parents c5d7c6f + b7ff70e commit 039932c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ More about my struggles can be read in Tiled Forum or Godot reddit. Check the Co
134134
- [x] Export TileSets from Tiled standalone tileset files
135135
- [x] Orthogonal maps
136136
- [ ] Isometric, staggered, and hexagonal maps
137-
- [ ] Export visibility and opacity from layers
137+
- [x] Export visibility and opacity from layers
138138
- [x] Export collision shapes<sup>*</sup>
139139
- [ ] Export occluder shapes<sup>*</sup>
140140
- [x] Export navigation shapes<sup>*</sup>

export_to_godot_tilemap.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GodotTilemapExporter {
6262

6363
/**
6464
* Generate a string with all tilesets in the map.
65-
* Godot allows only one tileset per tilemap so if you use more than one tileset per layer it's n ot going to work.
65+
* Godot allows only one tileset per tilemap so if you use more than one tileset per layer it's not going to work.
6666
* Godot supports several image textures per tileset but Tiled Editor doesn't.
6767
* Tiled editor supports only one tile
6868
* sprite image per tileset.
@@ -450,8 +450,6 @@ ${this.tileMapsString}
450450
* @returns {string}
451451
*/
452452
getTileMapTemplate(tileMapName, mode, tilesetID, poolIntArrayString, layer, parent = ".") {
453-
const tileWidth = layer.map.tileWidth === undefined ? 16 : layer.map.tileWidth;
454-
const tileHeight = layer.map.tileHeight === undefined ? 16 : layer.map.tileHeight;
455453
const groups = splitCommaSeparated(layer.property("groups"));
456454
const zIndex = parseInt(layer.properties()['z_index'], 10);
457455
return stringifyNode({
@@ -460,8 +458,11 @@ ${this.tileMapsString}
460458
parent: parent,
461459
groups: groups
462460
}, {
461+
visible: layer.visible,
462+
modulate: `Color( 1, 1, 1, ${layer.opacity} )`,
463+
position: `Vector2( ${layer.offset.x}, ${layer.offset.y} )`,
463464
tile_set: `ExtResource( ${tilesetID} )`,
464-
cell_size: `Vector2( ${tileWidth}, ${tileHeight} )`,
465+
cell_size: `Vector2( ${layer.map.tileWidth}, ${layer.map.tileHeight} )`,
465466
cell_custom_transform: `Transform2D( 16, 0, 0, 16, 0, 0 )`,
466467
format: 1,
467468
mode: mode,

0 commit comments

Comments
 (0)