Skip to content

Commit

Permalink
Fix: Build tilemap renderer from an empty tilemap to be able to creat…
Browse files Browse the repository at this point in the history
…e tilemaps in-game (#7181)
  • Loading branch information
AlexandreSi authored Nov 21, 2024
1 parent fbea483 commit 6ed0e8e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Extensions/TileMap/simpletilemapruntimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace gdjs {
readonly _tileSize: number;
_displayMode = 'all';
_layerIndex = 0;
_initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject | null = null;
_initialTileMapAsJsObject: TileMapHelper.EditableTileMapAsJsObject;
readonly _initialTilesWithHitBox: number[];
_isTileMapDirty: boolean = false;
_sceneToTileMapTransformation: gdjs.AffineTransformation = new gdjs.AffineTransformation();
Expand All @@ -66,6 +66,13 @@ namespace gdjs {
this._rowCount = objectData.content.rowCount;
this._columnCount = objectData.content.columnCount;
this._tileSize = objectData.content.tileSize;
this._initialTileMapAsJsObject = {
tileWidth: this._tileSize,
tileHeight: this._tileSize,
dimX: 1,
dimY: 1,
layers: [{ id: 0, alpha: this._opacity, tiles: [] }],
};
this._initialTilesWithHitBox = (objectData.content
.tilesWithHitBox as string)
.split(',')
Expand All @@ -79,6 +86,17 @@ namespace gdjs {
instanceContainer
);

this._loadInitialTileMap((tileMap: TileMapHelper.EditableTileMap) => {
this._renderer.updatePosition();

this._collisionTileMap = new gdjs.TileMap.TransformedCollisionTileMap(
tileMap,
this._hitBoxTag
);

this.updateTransformation();
});

// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
this.onCreated();
}
Expand Down

0 comments on commit 6ed0e8e

Please sign in to comment.