fixed bug with non-square tilemaps
This commit is contained in:
parent
201e1624c4
commit
033680cf52
|
@ -33,7 +33,7 @@ export default class TilemapFactory {
|
||||||
tilemap.forEachTile((tileIndex: number, i: number) => {
|
tilemap.forEachTile((tileIndex: number, i: number) => {
|
||||||
if(tileIndex !== 0){
|
if(tileIndex !== 0){
|
||||||
let x = (i % worldSize.x) * tileSize.x * 4;
|
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));
|
this.scene.physics.add(StaticBody, new Vec2(x, y), new Vec2(tileSize.x * 4, tileSize.y * 4));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ function main(){
|
||||||
pauseMenu.disable();
|
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++){
|
for(let i = 0; i < 30; i++){
|
||||||
let cc = foregroundLayer.canvasNode.add(ColoredCircle);
|
let cc = foregroundLayer.canvasNode.add(ColoredCircle);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"src/main.ts",
|
"src/main.ts",
|
||||||
"src/Player.ts",
|
"src/Player.ts",
|
||||||
|
|
||||||
"src/DataTypes/Tilesets/TiledData",
|
"src/DataTypes/Tilesets/TiledData.ts",
|
||||||
"src/DataTypes/Tilesets/Tileset",
|
"src/DataTypes/Tilesets/Tileset.ts",
|
||||||
"src/DataTypes/Collection.ts",
|
"src/DataTypes/Collection.ts",
|
||||||
"src/DataTypes/Map.ts",
|
"src/DataTypes/Map.ts",
|
||||||
"src/DataTypes/Queue.ts",
|
"src/DataTypes/Queue.ts",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user