-
Notifications
You must be signed in to change notification settings - Fork 113
Model for Serialization
Daan van Yperen edited this page May 25, 2017
·
1 revision
Ideally serialize references to assets instead of the assets themselves. Separating reference components and asset components keeps your serialized world lean.
When using Spine, create a separate SpineReference
and SpineRenderable
component.
@Transient
public class SpineRenderable extends Component {
public AnimationState state;
public Skeleton skeleton;
}
@PooledWeaver
public final class SpineReference extends Component {
public String path; // <- trivially serializable
}
@Transient exempts the component from serialization.
Create a system for each reference-asset pair which listens for unpaired references.
public class SpineResolver extends BaseEntitySystem {
public SpineResolver() {
super(all(Size.class, SpineReference.class).exclude(SpineRenderable.class));
}
@Override
protected void processSystem() {}
@Override
protected void inserted(int id) {
// once inserted, aspect.exclude(SpineRenderable.class) is longer satisfied.
// removing the SpineRenderable would immediately recreate it; can be useful
// when dealing with reloaded textures, editor tooling etc.
assignSpine(id);
}
}
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference