sshukul Posted December 31, 2018 Report Share Posted December 31, 2018 Hi I'm the maintainer of the implementation of Spriter for the Moai SDK game engine : https://github.com/sshukul/MoaiSpriter I was having some problems with rotations of sprites attached to bones which I'm guessing has to do with pivot points. Basically when I rotate a bone attached sprite, the pivot point seems off during the tween (images attached). The actual keyframes render correctly. This makes sense as right now my plugin just sets it to the default pivot point which is the top left corner of the sprite, but it looks like within Spriter the sprites attached to bones have their pivot points shifted to the bone's starting point. My question is: How is this bone based pivot point calculated from the SCML? I searched through the SCML Reference here but couldn't find anything: http://www.brashmonkey.com/ScmlDocs/ScmlReference.html The way the Moai game engine works is that I can pass it a pivot point for the rotation animations and it would render the rotations and tweens internally, but my plugin would have to perform the calculations for the pivot points. The closest I got was the unmapFromParent function which seems to recalculate the sprite's x and y coords independently when detached from a parent bone? Do I basically have to reverse this function to find out the x,y coords of the parent bone in relation to the sprite? Or am I off base here and the problem is just something else entirely? Quote Link to comment Share on other sites More sharing options...
lucid Posted December 31, 2018 Report Share Posted December 31, 2018 Hello. It should be the same math that you use to get a child bone position from a parent bone. Use that to calculate the pivot point from a sprite's location. So if you say that your sprite's position is like the parent bone's position, then the child in this situation would be at position (-pivot.x * scale.x * image.width, -pivot.y * scale.y * image.height), the resulting position of that transformation is where you should position the sprite. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.