Please help with an animation logic problem
Posted: Mon Jun 05, 2017 9:57 am
Hello, I have attached a file showing my problem with an animation. It is basically several image files, with a body, a head, two arms, and a wand.
I created some parent/child relationship. So the arms and head are children of the body. The wand is child of an arm.
Then, I created two functions, one function is "move", which moves the image. This one is no problem. The other function is "rotate", which rotates the image about a pivot point. This is a problem at the moment.
When you run my file, you can press "s" to rotate the body, which moves all its attached children along with it. No problem so far. But then, try pressing "f" to rotate the head. The problem here is that the head's rotation is always the same, but it should be relative to the body.
Could you please take a look at the code and see what is wrong with the coding logic? Here is brief description of all the files:
animations.lua: the main code for the animation.
main.lua: very short, this should be self-explanatory.
middleclass.lua: this is from kikito
pic.lua: very short class for animations, mainly it just draws the images along the center of the image.
sandbox.lua: the controls for moving the animations.
tween.lua: this is from kikito too.
I created some parent/child relationship. So the arms and head are children of the body. The wand is child of an arm.
Then, I created two functions, one function is "move", which moves the image. This one is no problem. The other function is "rotate", which rotates the image about a pivot point. This is a problem at the moment.
When you run my file, you can press "s" to rotate the body, which moves all its attached children along with it. No problem so far. But then, try pressing "f" to rotate the head. The problem here is that the head's rotation is always the same, but it should be relative to the body.
Could you please take a look at the code and see what is wrong with the coding logic? Here is brief description of all the files:
animations.lua: the main code for the animation.
main.lua: very short, this should be self-explanatory.
middleclass.lua: this is from kikito
pic.lua: very short class for animations, mainly it just draws the images along the center of the image.
sandbox.lua: the controls for moving the animations.
tween.lua: this is from kikito too.