I create a sprite, rotate it and then create and add a physics body to it. Everything works fine if there is no rotation applied (look at 1.) but when I rotate by 90 degrees the
physicsbody does not match the sprite rotation (look at 2.). What should I do so that after the rotation the physicsbody looks like in 3.?
My current code:
auto sprite = Sprite::create(filepath); sprite->setRotation(90); auto physicsBody = PhysicsBody::createBox(sprite->getContentSize(), PhysicsMaterial(10.0f, 1.0f, 2.0f)); physicsBody->setDynamic(true); sprite->setPhysicsBody(physicsBody); addChild(sprite);