{"action":"created","issue":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/4044","repository_url":"https://api.github.com/repos/photonstorm/phaser","labels_url":"https://api.github.com/repos/photonstorm/phaser/issues/4044/labels{/name}","comments_url":"https://api.github.com/repos/photonstorm/phaser/issues/4044/comments","events_url":"https://api.github.com/repos/photonstorm/phaser/issues/4044/events","html_url":"https://github.com/photonstorm/phaser/pull/4044","id":362065235,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2ODc4Nzc3","number":4044,"title":"Add setMaxSpeed() function.","user":{"login":"Edwin222","id":28051014,"node_id":"MDQ6VXNlcjI4MDUxMDE0","avatar_url":"https://avatars2.githubusercontent.com/u/28051014?v=4","gravatar_id":"","url":"https://api.github.com/users/Edwin222","html_url":"https://github.com/Edwin222","followers_url":"https://api.github.com/users/Edwin222/followers","following_url":"https://api.github.com/users/Edwin222/following{/other_user}","gists_url":"https://api.github.com/users/Edwin222/gists{/gist_id}","starred_url":"https://api.github.com/users/Edwin222/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Edwin222/subscriptions","organizations_url":"https://api.github.com/users/Edwin222/orgs","repos_url":"https://api.github.com/users/Edwin222/repos","events_url":"https://api.github.com/users/Edwin222/events{/privacy}","received_events_url":"https://api.github.com/users/Edwin222/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-20T08:04:01Z","updated_at":"2018-09-30T01:32:39Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/photonstorm/phaser/pulls/4044","html_url":"https://github.com/photonstorm/phaser/pull/4044","diff_url":"https://github.com/photonstorm/phaser/pull/4044.diff","patch_url":"https://github.com/photonstorm/phaser/pull/4044.patch"},"body":"Please do not update the README or Change Log, we will do this when we merge your PR.\r\n\r\nThis PR (delete as applicable)\r\n\r\n* Adds a new feature\r\n\r\nDescribe the changes below:\r\n\r\nI added setMaxSpeed() function requested on #4000 issue.\r\n\r\nThis function limits vector length of arcade physics body's velocity. I implemented it by checking vector length of new velocity value when Physics.Arcade.World  computes velocity.\r\n\r\nif it has maxSpeed value and new vector length is greater than max speed value, it decrease new velocity's X and Y value to fit max speed. formula used for this is based on trigonometric function so change of vector's direction from change of value is applied as normally.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/comments/425686614","html_url":"https://github.com/photonstorm/phaser/pull/4044#issuecomment-425686614","issue_url":"https://api.github.com/repos/photonstorm/phaser/issues/4044","id":425686614,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTY4NjYxNA==","user":{"login":"samme","id":435681,"node_id":"MDQ6VXNlcjQzNTY4MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/435681?v=4","gravatar_id":"","url":"https://api.github.com/users/samme","html_url":"https://github.com/samme","followers_url":"https://api.github.com/users/samme/followers","following_url":"https://api.github.com/users/samme/following{/other_user}","gists_url":"https://api.github.com/users/samme/gists{/gist_id}","starred_url":"https://api.github.com/users/samme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samme/subscriptions","organizations_url":"https://api.github.com/users/samme/orgs","repos_url":"https://api.github.com/users/samme/repos","events_url":"https://api.github.com/users/samme/events{/privacy}","received_events_url":"https://api.github.com/users/samme/received_events","type":"User","site_admin":false},"created_at":"2018-09-30T01:32:39Z","updated_at":"2018-09-30T01:32:39Z","author_association":"CONTRIBUTOR","body":"Just in case you're interested, this can also be done with the vector methods:\r\n\r\n```javascript\r\nif (body.velocity.length() > maxSpeed)\r\n{\r\n    body.velocity.normalize().scale(maxSpeed);\r\n}\r\n```"}}
{"actor":{"display_login":"samme"}}