excaliburjs/excalibur-tiled

Property class renamed to type again since Tiled v1.10.0

Closed this issue · 2 comments

This change of #384 was reverted since Tiled v1.10.0, see https://www.mapeditor.org/2023/03/10/tiled-1-10-released.html

It's still called Class in the GUI but in the file format it's type again, so I think we can name it Class but we should handle the type property or to remain backward compatible both properties type and class , something like this:

   public getObjectsByClass(type: string): TiledObject[] {
      return this.objects.filter(o => o.class?.toLocaleLowerCase() === type.toLocaleLowerCase() || o.type?.toLocaleLowerCase() === type.toLocaleLowerCase());
   }

@JumpLink Thanks for the issue!

I think this is a great way to handle this! Should we also add another method getObjectsByType()?

@eonarheim This method getObjectsByType() still exists in excalibur-tiled and is marked as deprecated since Tiled v1.9.0. Tiled originally wanted to change the property from type to class to be consistent, but there were too many complaints about this. So I think we can also call this class and not need a method called getObjectsByType even if the property is actually called type internally again for backward compatibility. I don't have any particular opinion about it and I don't know if the property type is needed for anything else either, but I suspect that this is not the case, otherwise it would become even more confusing.