Interface: Serializable

Serializable

Interface for classes that can be serialized. For saving and restoring game state. Subclass must override the `initializer` property. Implement one of these methods to customize behaviour:
  • objectToBeSerialized
  • toJSON
Implement one of these methods for restoration:
  • importFromSaveData
  • (static)restore

Members

(constant) initializer :string

The name of constructor the class, will be used to restore the object. The constructor has to be accessable via
window[initializer]
Type:
  • string

Methods

objectToBeSerialized(key) → {object|Serializable}

Return an object to be serialized for a specific key.
Parameters:
Name Type Description
key string The key of property to be serialized
Returns:
- An object or serializable to be saved for the specific key, return undefined = not to be saved.
Type
object | Serializable

toJSON() → {object|Serializable|Restorable}

Returns:
- An plain that can be serialized to json
Type
object | Serializable | Restorable