1
但是,我也想讓精靈的旋轉反映出b2bodies的旋轉。但是,在我旋轉精靈之後,我用來將它們正確對中於b2body位置的偏移量不再準確。Box2D C++圍繞點
void CRoom::RotateGun(const SDL_Event &event)
{
glm::vec2 mousePosition = sdl::GetMousePosition(event.motion);
glm::vec2 delta = mousePosition - GUN_POSITION;
float angle = atan2f(delta.y, delta.x);
m_gun->GetBody()->SetTransform(m_gun->GetPosition(), angle);
}