Skip to content

统一spine中 setAnimation 和 addAnimation 方法的结构. #18549

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

Closed
wants to merge 2 commits into from

Conversation

finscn
Copy link
Contributor

@finscn finscn commented Apr 2, 2025

非缓存模式下 , setAnimation 和 addAnimation 方法
除了 最终调用的 spine底层方法不一样之外, 其他的逻辑 应该完全一致.

这个 commit 的目的就是 统一两者的结构 :

  • 两者应该用同样的方式来判断 animation是否存在 并且给与同样的提示

  • 因为在判断 animation 是否存在时, 也判断了 this._skeleton 的有效性, 所以后面不用再做相关判断.

  • 经过测试, setAnimation 和 addAnimation 统一使用 this.state 下的相关方法是更好的选择.
    更新: 因为需要 _animState->apply(*_skeleton), 所以暂时不能用 state.setAnimationWith()

  • setAnimation() 中的 this._markForUpdateRenderData() 是多余的, 因为spine在update 时, 会调用这个方法.

Re: #

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

非缓存模式下 , setAnimation  和 addAnimation 方法
除了 最终调用的 spine底层方法不一样之外, 其他的逻辑 应该完全一致.

这个 commit  的目的就是 统一两者的结构 :

- 两者应该用同样的方式来判断 animation是否存在 并且给与同样的提示

- 因为在判断 animation 是否存在时, 也判断了 this._skeleton 的有效性, 所以后面不用再做相关判断.

- 经过测试,  setAnimation 和 addAnimation 统一使用 this.state 下的相关方法是更好的选择.

-  setAnimation() 中的 `this._markForUpdateRenderData()` 是多余的, 因为spine在update 时, 会调用这个方法.
@dumganhar dumganhar requested a review from bofeng-song April 2, 2025 06:26
Copy link

github-actions bot commented Apr 2, 2025

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1002457 bytes 1002457 bytes ✅ 0 bytes
2D All (legacy pipeline) 2664618 bytes 2664562 bytes 👍 -56 bytes
2D All (new pipeline) 2752826 bytes 2752770 bytes 👍 -56 bytes
(2D + 3D) All 10006413 bytes 10006357 bytes 👍 -56 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16920829 bytes 16920773 bytes 👍 -56 bytes

Interface Check Report

This pull request does not change any public interfaces !

经过测试

this._instance!.setAnimation() 和 this._state?.setAnimationWith() 并不等价.
前者比后者多了一个 updateWorldTransform() .
this._markForUpdateRenderData();

this._animationName = name;
const trackEntry = this._instance!.setAnimation(trackIndex, name, loop);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._instance is not working at cache mode.
This issue is scheduled to be resolved in an upcoming major version refactoring.

}
return null;

return this._state?.addAnimationWith(trackIndex, animation, loop, delay);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache-mode will cache animtion frame, so it can not be called immediately.

@finscn
Copy link
Contributor Author

finscn commented Apr 18, 2025

此 PR 作废.
最新版本见 : #18638

@finscn finscn closed this Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants