Callback for end of motion playback (Native)

[Last updated : 01/30/2020]



Cubism SDK for Native allows callbacks to retrieve events when motion playback ends.

In the sample, the callback function outputs log text to notify the end of playback.


Callback implementation

This time, because it processes by callback at the end of motion playback,
we have implemented callbacks in Framework/src/Motion/ACubismMotion, an abstract class that manages motion.



Please note that in the sample, callbacks cannot be invoked in the following conditions.

  • When the motion being played is set as “looping”
  • When NULL is registered in the callback


Using Callback Functions

Implement what you actually want to be processed in the callback function.

The sample implements the use of LAppPal::PrintLog() to output log text notifying the end of motion playback.
To change the processing at the end of motion playback, change the implementation of the following function.


The callback function is registered when CubismUserMotion::LoadMotion() is used in the Framework layer to load motion data, and the callback function is passed at the same time the motion is generated.
When there is already a motion, SetFinishedMotionHandler() introduced in “Callback Implementation” is used.

In the sample, the callback function is passed from StartRandomMotion(), which is called when OnTap() is executed to obtain the tap event.


In addition, since CubismMotion::DoUpdateParameters() is actually playing back the motion, the implementation is made so that the callback function can be passed to CubismMotion.



On the development of implementation

The sample implements only the end of motion playback, but by developing these implementations, asynchronous processing can be used in callback functions after motion playback is finished, or
by reverse engineering the function from the actual process to which the callback is to be applied, callbacks can be implemented at points other than the end of motion playback.

© 2010 - 2022 Live2D Inc.