add setAnimationFrame

This commit is contained in:
Nick Fisher
2023-02-26 12:21:36 +08:00
parent 20747f5cc8
commit 19f2d99ded
6 changed files with 26 additions and 3 deletions

View File

@@ -196,6 +196,10 @@ extern "C" {
((SceneAsset*)asset)->playAnimation(index, loop, reverse);
}
void set_animation_frame(void* asset, int animationIndex, int animationFrame) {
((SceneAsset*)asset)->setAnimationFrame(animationIndex, animationFrame);
}
int get_animation_count(void* asset) {
auto names = ((SceneAsset*)asset)->getAnimationNames();
return names->size();

View File

@@ -327,6 +327,12 @@ void SceneAsset::setTexture() {
}
void SceneAsset::setAnimationFrame(int animationIndex, int animationFrame) {
auto offset = 60 * animationFrame * 1000; // TODO - don't hardcore 60fps framerate
_animator->applyAnimation(animationIndex, offset);
_animator->updateBoneMatrices();
}
void SceneAsset::updateEmbeddedAnimations() {
auto now = high_resolution_clock::now();
int animationIndex = 0;