deko escribió
90% of the code assumes what you put in will exist. having null checks everywhere effects performance of the runtime. We do some pretty advance stuff with skeletons, getting animations to work with keys that we created/removed was a pain in my ass. in a general case, its best to assume Spine runtimes wont do the null checks and you should pass data in that you know exists. If you don't know if something exists you are doing something wrong in your workflow.
im not saying to do spAnimationState_addAnimationByName
im saying to use findby name...
We have this in our Set animation function
AssertAndReturn(spSkeletonData_findAnimation( animState->data->skeletonData, animName ),"Animation does not exists: %s",animName );
Why is spAnimationState_addAnimationByName
unuseful? How did you get the animations in the first place, did you create them? or did you get them on load?
using spAnimationState_addAnimation
just assumes the animation exists, seen as you can null check it if you need to, checking in the runtimes would be pointless, some people would want the check others would not. for example; Person A checks the skeleton on load and makes a list from all the animations from the skeletondata. Person B stores generic animations from multiple skeletons and plays them on the skeleton.
Person A wouldn't need to do the null check, he knows all the animations came from that skeleton so must exist.
Person B can not guarantee all animations exist, so must null check before entering that function.