I am on the cocos2dx runtime, which I replaced with the implementation on github as per the instructions, and have hit this wall. Guys, how do I flip a skeleton?
Well I actually can do that....but later I intervened the draw methods, and I cannot get info on whether or not each bone is also flipped....or do I have to go ask the root bone for this?
For flipping I used either
SkeletonNode here is a SkeletonAnimation.
skeletonNode->setScaleX(-1.0);
This flips the skeleton, but Xcode is autocompleting to the Node:: method, which suggests this isn't something that the spine runtime will be aware of later
On the other hand I come from the libgdx runtime, where I just did
skeletonNode.getRootBone().setFlipX(true);
But in cocos2dx I don't have that getRootBone method. Instead I tried
skeletonNode->findBone("root")->scaleX = -1;
Which works too.
So my real problem is later, in the draw method of SkeletonAnimation, I want to know whether a certain bone is flipped or not
if ((slot->bone->scaleX < 0) || _skeleton->flipX ) {
This if is never true, but on Libgdx I had
if (skeleton.getFlipX()) {
Which worked.
My libgdx code is from 2.1, my cocos2dx is from 3.1. I understand that flipping is no longer supported, but instead we gotta use negative scales, which makes sense, but I need to know if a particular bone has negative scale (for the typical normal texturing reasons).
What gives? Do I need to go through the whole skeleton to check if a certain bone is flipped? Consider that some animations may have one of the bones with a negative scale, so if the whole skeleton is flipped, that one bone should be left on the original orientation.
edit: wait I jumped the gun on this, on SkeletonRenderer, the variable _skeleton has -> root so I can just ask
bool scaleX = _skeleton->root->scaleX < 0;
Still gotta check the case where one bone is flipped during an unflipped animation, but I don't think I have a case right now, and don't have the editor in front of me.
Thanks anyway.