Need help with designing a Tween based animation system

Probably an asset or similar. Else it’s like putting a mesh in a component, eh?

1 Like

I see, thanks for your response.
Will put them in client side.
Maybe inform of a j3o file (as string in User Data) to be able to load it with asset manager out of the box. Or maybe as a plain text file with a specific loader registered in asset manager.

Paul I managed to make it work with a custom loader.

I registered a TweenLoader in asset manager

public class TweenLoader implements AssetLoader {

    private static Gson gson;

    static {
        gson = new GsonBuilder()
                .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(TweenBuilder.class, "cType")

    public static Gson getGson() {
        return gson;

    public Object load(AssetInfo assetInfo) throws IOException {
        return loadFromStream(assetInfo, assetInfo.openStream());

    private Object loadFromStream(AssetInfo assetInfo, InputStream stream) throws IOException {
        try {
            return gson.fromJson(new JsonReader(new InputStreamReader(stream)), TweenBuilder.class);
        } catch (Exception e) {
            throw new AssetLoadException("An error occurred loading tween " + assetInfo.getKey().getName(), e);
        } finally {

now I save it like this in the editor :

try (FileWriter writer = new FileWriter(filePath)) {
     TweenLoader.getGson().toJson(tween.getModel(), TweenBuilder.class, writer);
} catch (IOException ex) {
     getState(OptionPanelState.class, true).showError("Error Saving !", ex);

and here is an example TweenBuilder exporeted to a file “test.tween”.


Now after call to build() method of this TweenBuilder at runtime, it will create a Sequence tween consists of a Delay tween and a CallMethod tween which calls “play” method on an AudioNode.