{"action":"created","issue":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/3551","repository_url":"https://api.github.com/repos/photonstorm/phaser","labels_url":"https://api.github.com/repos/photonstorm/phaser/issues/3551/labels{/name}","comments_url":"https://api.github.com/repos/photonstorm/phaser/issues/3551/comments","events_url":"https://api.github.com/repos/photonstorm/phaser/issues/3551/events","html_url":"https://github.com/photonstorm/phaser/pull/3551","id":313849419,"number":3551,"title":"Allow tween onComplete listeners to affect tween state","user":{"login":"Cudabear","id":6170636,"avatar_url":"https://avatars3.githubusercontent.com/u/6170636?v=4","gravatar_id":"","url":"https://api.github.com/users/Cudabear","html_url":"https://github.com/Cudabear","followers_url":"https://api.github.com/users/Cudabear/followers","following_url":"https://api.github.com/users/Cudabear/following{/other_user}","gists_url":"https://api.github.com/users/Cudabear/gists{/gist_id}","starred_url":"https://api.github.com/users/Cudabear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cudabear/subscriptions","organizations_url":"https://api.github.com/users/Cudabear/orgs","repos_url":"https://api.github.com/users/Cudabear/repos","events_url":"https://api.github.com/users/Cudabear/events{/privacy}","received_events_url":"https://api.github.com/users/Cudabear/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-12T19:02:42Z","updated_at":"2018-04-26T12:07:17Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/photonstorm/phaser/pulls/3551","html_url":"https://github.com/photonstorm/phaser/pull/3551","diff_url":"https://github.com/photonstorm/phaser/pull/3551.diff","patch_url":"https://github.com/photonstorm/phaser/pull/3551.patch"},"body":"Set the state of the tween to PENDING_REMOVE before calling the onComplete listener of the tween to allow the `onComplete` listener to affect the tween state and not be immediately overwritten upon finishing execution.\r\n\r\nThis is useful for conditionally restarting the tween upon its completion.\r\n\r\nExample:\r\n\r\n```\r\n        var me = this;\r\n        this.myTween = this.add.tween({\r\n            targets: this.mySprite,\r\n            x: 300,\r\n            duration: 3000,\r\n            onComplete: function(){\r\n                if(someConditional){\r\n                    me.myTween.restart();\r\n                }\r\n            }\r\n        });\r\n```\r\n\r\nBefore this change, the `restart` call's state change would be overwritten immediately after leaving execution of the on complete. "},"comment":{"url":"https://api.github.com/repos/photonstorm/phaser/issues/comments/384617212","html_url":"https://github.com/photonstorm/phaser/pull/3551#issuecomment-384617212","issue_url":"https://api.github.com/repos/photonstorm/phaser/issues/3551","id":384617212,"user":{"login":"photonstorm","id":164476,"avatar_url":"https://avatars2.githubusercontent.com/u/164476?v=4","gravatar_id":"","url":"https://api.github.com/users/photonstorm","html_url":"https://github.com/photonstorm","followers_url":"https://api.github.com/users/photonstorm/followers","following_url":"https://api.github.com/users/photonstorm/following{/other_user}","gists_url":"https://api.github.com/users/photonstorm/gists{/gist_id}","starred_url":"https://api.github.com/users/photonstorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/photonstorm/subscriptions","organizations_url":"https://api.github.com/users/photonstorm/orgs","repos_url":"https://api.github.com/users/photonstorm/repos","events_url":"https://api.github.com/users/photonstorm/events{/privacy}","received_events_url":"https://api.github.com/users/photonstorm/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T12:07:17Z","updated_at":"2018-04-26T12:07:17Z","author_association":"OWNER","body":"I'm going to leave this PR for now as I'll change how tween callbacks work very soon (re: the discussion about it in the issues) - I'll keep this open so I can refer to it then."}}
{"actor":{"display_login":"photonstorm"}}