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

 Share

  • Recently Browsing   0 members

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