The center point of the bar is in the middle of the screen.
A ball sits on top of this bar and will roll from left to right and vice versa when it tilts the other way.
It is all working apart from the ball will looks a little off the line by about 2-4 pixels in the air when it tilt downward like it not able to catch up the falling momentum of the see-saw.
// m_floor_angle value ranges from -10.0f to 10.0f
Code: Select all
cpFloat floorAngle = m_floor_angle < 0 ? 360 + m_floor_angle : m_floor_angle;
cpFloat a = fmod(floorAngle * M_PI / 180.0f, 360);
m_moveableFloorBody->w = 0.0f;
cpBodySetAngle(m_moveableFloorBody, a);
cpSpaceReindexShapesForBody(m_space, m_moveableFloorBody);
I've tried various other things such as setting the ball velocity to make it catch up the falling see-saw but it doesn't seem to work well.
Is there a solution to this?