Anchor points?
tollhousestudio
Member Posts: 166
I know there isn't a feature in GS but I've been making a game with gravity, and I was just playing around and thought anchor points would be sweet!
like the hands of a clock, anchored to the middle of the face. I know there is ways to emitate this sorta thing but I needed it to work with the gravity not a rule.
Any suggestions good people?
like the hands of a clock, anchored to the middle of the face. I know there is ways to emitate this sorta thing but I needed it to work with the gravity not a rule.
Any suggestions good people?
Comments
if you are not dealing with collision you can use the sin and cos functions to calculate rotational offset. This will allow you to rotate an arm on the face of a clock. The key being that it doesn't act under forces and impacts.
posX = initialX + cos(angle) * width / 2
(to calculate Y use the sin function)
This works fine as long as you are not doing any sort of collision with the "arm" because the game salad engine uses the point of impact to calculate the rotational force. This means that it always thinks the anchor point is in the middle when calculating an impact force.
For impact forces I have not found a good solution. The best work-around I've come up with is to have a long bar and half of the bar's image is alpha 0. Therefor it LOOKS like it's anchored at one end but in reality it's just a long bar rotating around its central axis.
The problem with this is that you have this big invisible arm sticking out that is prone to collision detection. There is no easy way to detect which half of the arm has received impact data, the visible or the invisible half.
The solution is anchor points. The work arounds are so-so.
I'd love to hear if someone else has a better solution to this!