Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spine] 安卓原生平台, 无法通过代码控制spine动画的播放进度. #17998

Open
finscn opened this issue Dec 2, 2024 · 1 comment
Assignees
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@finscn
Copy link
Contributor

finscn commented Dec 2, 2024

Cocos Creator version

3.8.4

System information

android

Issue description

后面附有可重现此问题的demo.

其核心代码 如下:

import { _decorator, Component, sp } from 'cc';
const { ccclass, property } = _decorator;

@ccclass
export class TestSpine extends Component {

    @property(sp.Skeleton)
    spine: sp.Skeleton

    progress: number = 0
    speed: number = 0.5

    start() {
        this.spine.clearAnimations();
        this.spine.setToSetupPose();
        this.spine.paused = false;
        this.updateSpineProgress(this.spine, 'Rotate', this.progress)
    }

    update(deltaTime: number) {
        this.progress += this.speed * deltaTime
        this.updateSpineProgress(this.spine, 'Rotate', this.progress)
    }

    updateSpineProgress(spine: sp.Skeleton, animName: string, progress: number, trackIndex: number = 0): void {
        progress = progress % 1;

        const trackEntry = spine.setAnimation(trackIndex, animName, false);
        const animation = trackEntry.animation;

        const duration = animation.duration;
        const time = duration * progress;
        trackEntry.animationStart = time;
        trackEntry.animationEnd = time;
        trackEntry.timeScale = 0;
    }

}

代码意图: 不让动画自己播放, 而是程序控制它的播放进度.

该代码在 web 和 微信小游戏 抖音小游戏 中都正常运行 符合预期.
但是在 安卓原生平台, 代码无效, 也不报错.

demo 如下
native-spine-bug.zip


另外想咨询下, 有什么更好的方式 通过代码控制 spine的播放进度吗?

.

Relevant error log output

No response

Steps to reproduce

如上

Minimal reproduction project

No response

@finscn
Copy link
Contributor Author

finscn commented Dec 12, 2024

好像把 timeScale = 0 去掉 原生和非原生就都能播放了.
但是 timeScale = 0 时, 原生和非原生 的行为不一致, 这种也算是bug吧. 到底哪边对 我也不知道了...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants