{"action":"created","issue":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/2494","repository_url":"https://api.github.com/repos/photonstorm/phaser","labels_url":"https://api.github.com/repos/photonstorm/phaser/issues/2494/labels{/name}","comments_url":"https://api.github.com/repos/photonstorm/phaser/issues/2494/comments","events_url":"https://api.github.com/repos/photonstorm/phaser/issues/2494/events","html_url":"https://github.com/photonstorm/phaser/issues/2494","id":156127187,"number":2494,"title":"[feature request] Rotation tweens should move in the direction of the shortest distance","user":{"login":"ForgeableSum","id":4404920,"avatar_url":"https://avatars.githubusercontent.com/u/4404920?v=3","gravatar_id":"","url":"https://api.github.com/users/ForgeableSum","html_url":"https://github.com/ForgeableSum","followers_url":"https://api.github.com/users/ForgeableSum/followers","following_url":"https://api.github.com/users/ForgeableSum/following{/other_user}","gists_url":"https://api.github.com/users/ForgeableSum/gists{/gist_id}","starred_url":"https://api.github.com/users/ForgeableSum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ForgeableSum/subscriptions","organizations_url":"https://api.github.com/users/ForgeableSum/orgs","repos_url":"https://api.github.com/users/ForgeableSum/repos","events_url":"https://api.github.com/users/ForgeableSum/events{/privacy}","received_events_url":"https://api.github.com/users/ForgeableSum/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/photonstorm/phaser/labels/feature%20request","name":"feature request","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-05-21T23:52:00Z","updated_at":"2016-07-29T01:31:20Z","closed_at":null,"body":"Suppose I have a tank and I want to turn it to a specific angle using a rotation tween. The problem with the tween system now is that it only adds or subtracts a value to achieve the target value, but that simply logic doesn't work when you are dealing with angles. The function below will tell you wether adding to the rotation is the shortest direction to turn in to achieve a target angle. Given a current and target angle, when returning true, the tween manager should add, when returning false, it should subtract. That way you don't have the tank do an almost 360 spin to turn less than 10 degrees! Hopefully this code can be implemented in core as I think it is intuitive the tweening should work this way. \r\n\r\n```\r\nfunction addIsShortestDistanceToRotation(rotationAt, rotationGoing) {\r\n\r\n    rotationAt = Phaser.Math.normalizeAngle(rotationAt);\r\n    rotationGoing = Phaser.Math.normalizeAngle(rotationGoing);\r\n\r\n    if ((rotationAt < rotationGoing) && ((rotationGoing - rotationAt) <= Math.PI)) {\r\n        return true;\r\n    }\r\n\r\n    if ((rotationAt < rotationGoing) && ((rotationGoing - rotationAt) > Math.PI)) {\r\n        return false;\r\n    }\r\n\r\n    if ((rotationAt > rotationGoing) && ((rotationAt - rotationGoing) <= Math.PI)) {\r\n        return false;\r\n    }\r\n\r\n    if ((rotationAt > rotationGoing) && ((rotationAt - rotationGoing) > Math.PI)) {\r\n        return true;\r\n    }\r\n\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/comments/236072054","html_url":"https://github.com/photonstorm/phaser/issues/2494#issuecomment-236072054","issue_url":"https://api.github.com/repos/photonstorm/phaser/issues/2494","id":236072054,"user":{"login":"hilts-vaughan","id":1079207,"avatar_url":"https://avatars.githubusercontent.com/u/1079207?v=3","gravatar_id":"","url":"https://api.github.com/users/hilts-vaughan","html_url":"https://github.com/hilts-vaughan","followers_url":"https://api.github.com/users/hilts-vaughan/followers","following_url":"https://api.github.com/users/hilts-vaughan/following{/other_user}","gists_url":"https://api.github.com/users/hilts-vaughan/gists{/gist_id}","starred_url":"https://api.github.com/users/hilts-vaughan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hilts-vaughan/subscriptions","organizations_url":"https://api.github.com/users/hilts-vaughan/orgs","repos_url":"https://api.github.com/users/hilts-vaughan/repos","events_url":"https://api.github.com/users/hilts-vaughan/events{/privacy}","received_events_url":"https://api.github.com/users/hilts-vaughan/received_events","type":"User","site_admin":false},"created_at":"2016-07-29T01:31:20Z","updated_at":"2016-07-29T01:31:20Z","body":"Hi,\r\n\r\nI'll write a Phaser sandbox example. :)"}}
{"actor":{"display_login":"hilts-vaughan"}}