{"action":"created","issue":{"url":"https://api.github.com/repos/bjorn/tiled/issues/955","labels_url":"https://api.github.com/repos/bjorn/tiled/issues/955/labels{/name}","comments_url":"https://api.github.com/repos/bjorn/tiled/issues/955/comments","events_url":"https://api.github.com/repos/bjorn/tiled/issues/955/events","html_url":"https://github.com/bjorn/tiled/issues/955","id":78084116,"number":955,"title":"How to rotate objects and positionate correctly?","user":{"login":"MrJookie","id":8093682,"avatar_url":"https://avatars.githubusercontent.com/u/8093682?v=3","gravatar_id":"","url":"https://api.github.com/users/MrJookie","html_url":"https://github.com/MrJookie","followers_url":"https://api.github.com/users/MrJookie/followers","following_url":"https://api.github.com/users/MrJookie/following{/other_user}","gists_url":"https://api.github.com/users/MrJookie/gists{/gist_id}","starred_url":"https://api.github.com/users/MrJookie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrJookie/subscriptions","organizations_url":"https://api.github.com/users/MrJookie/orgs","repos_url":"https://api.github.com/users/MrJookie/repos","events_url":"https://api.github.com/users/MrJookie/events{/privacy}","received_events_url":"https://api.github.com/users/MrJookie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-19T13:19:57Z","updated_at":"2015-05-19T14:01:24Z","closed_at":null,"body":"In my game I am trying to rotate tiled objects, but unsuccessfully. They're placed at wrong X and Y position. Thanks for suggestions.\r\n\r\n\t\t\t    position.x = atof(objectElement->first_attribute(\"x\")->value());\r\n\t\t\t    position.y = atof(objectElement->first_attribute(\"y\")->value());\r\n\r\n\t\t\t\tfloat rotationAngle = objectElement->first_attribute(\"rotation\") ? atof(objectElement->first_attribute(\"rotation\")->value()) : 0.0;\r\n\r\n\t\t\t\tfloat centerX = tilewidth / 2;\r\n\t\t\t\tfloat centerY = tileheight / 2;\r\n\r\n\t\t\t\tfloat cosRotation = cos(-rotationAngle * M_PI / 180.0);\r\n\t\t\t\tfloat sinRotation = sin(-rotationAngle * M_PI / 180.0);\r\n\r\n\t\t\t\tfloat rotatedCenterX = centerX * cosRotation - centerY * sinRotation;\r\n\t\t\t\tfloat rotatedCenterY = centerX * sinRotation + centerY * cosRotation;\r\n\r\n\t\t\t\tposition.x = position.x + rotatedCenterX;\r\n\t\t\t\tposition.y = position.y + rotatedCenterY;\r\n\r\n\t\t\t\tsprite.setPosition(position.x, position.y);\r\n\r\n\t\t\t\tsprite.setOrigin(centerX, centerY);\r\n\t\t\t\tsprite.setRotation(rotationAngle);"},"comment":{"url":"https://api.github.com/repos/bjorn/tiled/issues/comments/103507588","html_url":"https://github.com/bjorn/tiled/issues/955#issuecomment-103507588","issue_url":"https://api.github.com/repos/bjorn/tiled/issues/955","id":103507588,"user":{"login":"MrJookie","id":8093682,"avatar_url":"https://avatars.githubusercontent.com/u/8093682?v=3","gravatar_id":"","url":"https://api.github.com/users/MrJookie","html_url":"https://github.com/MrJookie","followers_url":"https://api.github.com/users/MrJookie/followers","following_url":"https://api.github.com/users/MrJookie/following{/other_user}","gists_url":"https://api.github.com/users/MrJookie/gists{/gist_id}","starred_url":"https://api.github.com/users/MrJookie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrJookie/subscriptions","organizations_url":"https://api.github.com/users/MrJookie/orgs","repos_url":"https://api.github.com/users/MrJookie/repos","events_url":"https://api.github.com/users/MrJookie/events{/privacy}","received_events_url":"https://api.github.com/users/MrJookie/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T14:01:24Z","updated_at":"2015-05-19T14:01:24Z","body":"SFML http://www.sfml-dev.org/documentation/2.3/classsf_1_1Sprite.php"}}