Hello,
I've just recently downloaded the spine-sfml runtime and have been trying my hands on with it using the example animations. While doing so, I've been trying to implement scaling and rotation on the skeletons. With some digging in, I figured out how to do so, however I've come across an issue where the scaling and rotation do not occur according to the root.
For scaling, I've tried using 2 approaches that seemed to work-
1)
m_Scale = sf::Vector2f(_startScale, _startScale);
for (int iBone = 0; iBone < m_Skeleton->boneCount; ++iBone)
{
m_Skeleton->bones[iBone]->data->inheritScale = true;
}
m_Skeleton->root->data->scaleX = m_Scale.x;
m_Skeleton->root->data->scaleY = m_Scale.y;
2)
m_Scale = sf::Vector2f(_startScale, _startScale);
for (int iBone = 0; iBone < m_Skeleton->boneCount; ++iBone)
{
m_Skeleton->bones[iBone]->data->inheritScale = true;
m_Skeleton->bones[iBone]->data->scaleX = m_Scale.x;
m_Skeleton->bones[iBone]->data->scaleY = m_Scale.y;
}
However, in both cases, the position of the skeleton that I get from m_Skeleton->x and m_Skeleton->y remains constant, which is expected, but the scaling seems to happen with respect to the center of the skeleton and not the position of the root which is unexpected. If I could either get m_Skeleton->x and m_Skeleton->y to change to the new expected root or get the scaling to happen with respect to the existing root, that would be great.
Any help on how I could fix this would be much appreciated.
Well, found a solution to this, but don't know how good it is. The positioning and scaling everything seems to work fine if I just use m_Skeleton->root->data as the bone for all scaling, rotation and positioning operations. But what I can't seem to get is why using m_Skeleton->x and m_Skeleton->y is recommended for positioning purposes if scaling and rotation operations don't work fine on them. Its either that or that I've done something wrong, the latter being more probable. And I'd rather like to know where I messed up in the process.