Notes Specific to the Java Version

Updated: 01/26/2023

Allocator, Memory-Related

Unlike Cubism SDK for Native, variables and objects that are no longer needed are freed by garbage collection and must be properly dereferenced.
Also, there is no need to pass an allocator (ICubismAllocator) as the first argument to the CubismFramework.startUp() for the reasons above.

See “How to Use CubismJavaFramework Directly” for detailed instructions.

Texture Formats

In order for Android’s BitmapFactory.decodeStream method to generate images using the Premultiplied Alpha method, PREMULTIPLIED_ALPHA_ENABLE defined in the sample LAppDefine must be set to true.

if (LAppDefine.PREMULTIPLIED_ALPHA_ENABLE) {
    this.<CubismRendererAndroid>getRenderer().isPremultipliedAlpha(true);
} else {
    this.<CubismRendererAndroid>getRenderer().isPremultipliedAlpha(false);
}

Handling of Callback Functions in Cubism SDK for Java

Cubism SDK for Java has callback functions that can be registered in the same way as Native and Web, but there are some differences in usage due to Java specifications.
Since the methods themselves cannot be managed as objects, callback function objects are handled by having the user create a class that implements the interface we have provided.

private static class FinishedMotion implements IFinishedMotionCallback {
    @Override
    public void execute(ACubismMotion motion) {
        LAppPal.printLog("Motion Finished: " + motion);
    }
}

private static final FinishedMotion finishedMotion = new FinishedMotion();

When passing callbacks, this object should be passed as a function argument.

public void onTap(float x, float y) {
    ...
    for (LAppModel model : models){
        ...
        model.startRandomMotion(MotionGroup.TAP_BODY.getId(), Priority.NORMAL.getPriority(), finishedMotion);
        ...
    }
}

See the “Callback for End of Motion Playback (Java)” page for more specific usage.

Was this article helpful?
YesNo
Please let us know what you think about this article.