Skip to content

Commit

Permalink
added some comments to addobjects.. helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
insulationman committed Jul 25, 2023
1 parent 50ddd41 commit c29fd60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Helpers/TileHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ export function AddObjectsFromObjectLayer(
objectLayerName: string,
spritesheetName: string
): Phaser.Physics.Arcade.StaticGroup {
//create a group of static arcade objects that is added to the scene.
const group = scene.physics.add.staticGroup();
//get all objects contained in the specified object layer
const objects = map.getObjectLayer(objectLayerName)["objects"];
//add all objects in the layer and add them to the mushrooms list
//add all objects in the layer to the group of static arcade objects
objects.forEach((object) => {
//get the tile image number of the tile (e.g. the image of a mushroom that is on the 605th frame of the image sheet)
const tileArtId = object["gid"] ? object["gid"] - 1 : 0;
//then create an object that uses the spritesheet (the image containing all tile artwork), and the frame related to this specific tile.
group.create(object.x, object.y, spritesheetName, tileArtId);
});
return group;
Expand Down

0 comments on commit c29fd60

Please sign in to comment.