Skip to content

Commit

Permalink
fix: [#446] Property class renamed to type again (#447)
Browse files Browse the repository at this point in the history
Fixes #446
  • Loading branch information
JumpLink authored Jul 5, 2023
1 parent 0fe3031 commit d38bb58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tiled-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ export class TiledObjectGroup extends TiledEntity {
return this.objects.filter(o => o.type?.toLocaleLowerCase() === type.toLocaleLowerCase());
}

/**
* Since Tiled 1.10 the property is called `type` again.
* We treat both properties here to be on the safe side.
* See https://doc.mapeditor.org/en/stable/reference/tmx-changelog/#tiled-1-10
*/
public getObjectsByClass(type: string): TiledObject[] {
return this.objects.filter(o => o.class?.toLocaleLowerCase() === type.toLocaleLowerCase());
return this.objects.filter(o => o.class?.toLocaleLowerCase() === type.toLocaleLowerCase() || o.type?.toLocaleLowerCase() === type.toLocaleLowerCase());
}

public getObjectByName(name: string): TiledObject | undefined {
Expand Down Expand Up @@ -204,4 +209,4 @@ export interface TiledText {

export interface TiledInsertedTile extends TiledObject {
gid: number;
}
}

0 comments on commit d38bb58

Please sign in to comment.