fixed bug with non-square tilemaps

This commit is contained in:
Joe Weaver 2020-08-18 11:54:16 -04:00
parent 201e1624c4
commit 033680cf52
3 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ export default class TilemapFactory {
tilemap.forEachTile((tileIndex: number, i: number) => {
if(tileIndex !== 0){
let x = (i % worldSize.x) * tileSize.x * 4;
let y = Math.floor(i / worldSize.y) * tileSize.y * 4;
let y = Math.floor(i / worldSize.x) * tileSize.y * 4;
this.scene.physics.add(StaticBody, new Vec2(x, y), new Vec2(tileSize.x * 4, tileSize.y * 4));
}
});

View File

@ -78,7 +78,7 @@ function main(){
pauseMenu.disable();
}
mainScene.tilemap.add(OrthogonalTilemap, "assets/tilemaps/SmallTest.json");
mainScene.tilemap.add(OrthogonalTilemap, "assets/tilemaps/Platformer.json");
for(let i = 0; i < 30; i++){
let cc = foregroundLayer.canvasNode.add(ColoredCircle);

View File

@ -3,8 +3,8 @@
"src/main.ts",
"src/Player.ts",
"src/DataTypes/Tilesets/TiledData",
"src/DataTypes/Tilesets/Tileset",
"src/DataTypes/Tilesets/TiledData.ts",
"src/DataTypes/Tilesets/Tileset.ts",
"src/DataTypes/Collection.ts",
"src/DataTypes/Map.ts",
"src/DataTypes/Queue.ts",