Skip to content

Commit 6ed0e8e

Browse files
authored
Fix: Build tilemap renderer from an empty tilemap to be able to create tilemaps in-game (#7181)
1 parent fbea483 commit 6ed0e8e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Extensions/TileMap/simpletilemapruntimeobject.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace gdjs {
4545
readonly _tileSize: number;
4646
_displayMode = 'all';
4747
_layerIndex = 0;
48-
_initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject | null = null;
48+
_initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;
4949
readonly _initialTilesWithHitBox: number[];
5050
_isTileMapDirty: boolean = false;
5151
_sceneToTileMapTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
@@ -66,6 +66,13 @@ namespace gdjs {
6666
this._rowCount = objectData.content.rowCount;
6767
this._columnCount = objectData.content.columnCount;
6868
this._tileSize = objectData.content.tileSize;
69+
this._initialTileMapAsJsObject = {
70+
tileWidth: this._tileSize,
71+
tileHeight: this._tileSize,
72+
dimX: 1,
73+
dimY: 1,
74+
layers: [{ id: 0, alpha: this._opacity, tiles: [] }],
75+
};
6976
this._initialTilesWithHitBox = (objectData.content
7077
.tilesWithHitBox as string)
7178
.split(',')
@@ -79,6 +86,17 @@ namespace gdjs {
7986
instanceContainer
8087
);
8188

89+
this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {
90+
this._renderer.updatePosition();
91+
92+
this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(
93+
tileMap,
94+
this._hitBoxTag
95+
);
96+
97+
this.updateTransformation();
98+
});
99+
82100
// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
83101
this.onCreated();
84102
}

0 commit comments

Comments
 (0)