You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
So that entities can be stored and loaded from files, implement a deserialization scheme that component classes can implement. One possible way is to register component deserialization methods in the scene based on a unique string. For example, this JSON could represent an entity:
{ "position" : { x: 12, y: 24 } }
The LGPosition component could register for it like this in the scene:
Perhaps a Deserializable protocol could work, then registering is simply associating a string with a class. It would be nice if Swift let us use Types as Dictionary keys and values.
The text was updated successfully, but these errors were encountered:
#26 implements #25, which will add the ability for the tmx parser to load tmx <object> elements into memory. These elements have a type attribute that could indicate some kind of template, as well as custom property key-value pairs that could indicate components like this (similar to the above example):
Key
Value
position
{ x: 12, y: 24 }
sprite
{ spriteSheet: "Player" }
As proposed before, LGPosition and LGSprite would register to be deserializers for "position" and "sprite" respectively.
Better yet, with the possibility of using type as a template indicator, the game could define templates in a json object somewhere and just use the property values to override or add to the template-created entity.
thelukester92
changed the title
Implement an extensible deserialization scheme
Implement an extensible deserialization scheme that can work with tmx objects
Jul 31, 2014
So that entities can be stored and loaded from files, implement a deserialization scheme that component classes can implement. One possible way is to register component deserialization methods in the scene based on a unique string. For example, this JSON could represent an entity:
The
LGPosition
component could register for it like this in the scene:And the result of deserialization would be this:
Perhaps a Deserializable protocol could work, then registering is simply associating a string with a class. It would be nice if Swift let us use Types as Dictionary keys and values.
The text was updated successfully, but these errors were encountered: