Jump to content

Basic JS - Tween issue


uyerdna
 Share

Recommended Posts

Hi guys

 

I'm still really new in this whole JS thing so I get easily confused while writing down my ideas. Currently I'm stuck with writing tween correctly. Would be great if someone can see my code and tell me what's wrong

 

this.readyText = new Phaser.BitmapText(this.game, this.game.width/2 - 100, 500, 'littera', 'R E A D Y', 42);this.readyTween = this.game.add.tween(this.readyText).to( { y: this.game.height/2 }, 500, Phaser.Easing.Linear.None, true);this.readyTween.onComplete.addOnce(function(){      this.readyText.text = 'SET'; // want to change the text, but it won't work      this.readyTween.to( { y: 600 }, 500, Phaser.Easing.Linear.None, true); // try to tween it but won't work either      });

Seems like I'm lost in this whole 'this' scope thingy in JS. I'd really grateful if someone could point me to the right direction. I'm using Phaser 2.2.2. Thanks in advance!

 

 

Link to comment
Share on other sites

Just try this note("this" word added as last parameter in the very end of your code):

            this.readyText = new Phaser.BitmapText(this.game, this.game.width / 2 - 100, 500, 'littera', 'R E A D Y', 42);            this.readyTween = this.game.add.tween(this.readyText).to({ y: this.game.height / 2 }, 500, Phaser.Easing.Linear.None, true);            this.readyTween.onComplete.addOnce(function () {                this.readyText.text = 'SET'; // want to change the text, but it won't work                this.readyTween.to({ y: 600 }, 500, Phaser.Easing.Linear.None, true); // try to tween it but won't work either            }, this);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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