Skip to content

Commit

Permalink
Start from an empty tilemap to be able to create tilemaps in-game
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSi committed Nov 21, 2024
1 parent 44b18cb commit 8ffaa6c
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 8ffaa6c

Please sign in to comment.