Jump to content

Bug: Tweening the world, bad callback context


stamas47
 Share

Recommended Posts

Forget what I said, the listenerContext is the "this". So my bad.

In any case, it would be great if we could get a named return for the context, so as to not have to localize and classifiy the "this" in the callback scope.

Example: where "this" is a Minigame class

 this.game.add.tween(this.game.world).to({ alpha: 0 }, 1000, Phaser.Easing.Circular.Out, true).onComplete.add(function (_world:Phaser.World,_tween:Phaser.Tween,_minigame:Minigame) {

            _minigame.Destroy();
 },this)

instead of the current possbile solution

 this.game.add.tween(this.game.world).to({ alpha: 0 }, 1000, Phaser.Easing.Circular.Out, true).onComplete.add(function () {
            (_minigame as Minigame).Destroy();
 },this)

or ( but I dont like this approach, for if I need the context more than once, I would have to write "as" that many times )

 this.game.add.tween(this.game.world).to({ alpha: 0 }, 1000, Phaser.Easing.Circular.Out, true).onComplete.add(function () {

            (this as Minigame).Destroy();
 },this)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...