Jump to content

Tweening text


Natman
 Share

Recommended Posts

I'm trying to use tweens to transition a menu off of the screen. The menu contains a backdrop sprite and several Text objects. When it's closed, I create tweens to move all of these elements upward off the screen.

 

For some reason, the backdrop tweens perfectly and the text doesn't move at all, even though the code is basically the same:

//tween upwardsvar tween = game.add.tween(this.backdrop);tween.to({y: -this.backdrop.height}, 500, Phaser.Easing.Linear.None, true);tween.onComplete.add(this.destroy, this);game.add.tween(this.titleText1).to({y: this.titleText1.y - this.backdrop.height}, 500, Phaser.Easing.Linear.None, true);game.add.tween(this.titleText2).to({y: this.titleText2.y - this.backdrop.height}, 500, Phaser.Easing.Linear.None, true);game.add.tween(this.msgText).to({y: this.msgText.y - this.backdrop.height}, 500, Phaser.Easing.Linear.None, true);

The onComplete event I attach to the backdrop tween is for triggering the actually destruction of the menu.

 

I'm using Phaser 2.0 and I don't want to upgrade for my current project.

 

Link to comment
Share on other sites

Getting any console errors?

 

I'd try isolating the issue to something as narrow as possible.

 

First I'd get rid of the tween on the backdrop and make sure that's not somehow affecting the other ones (maybe the onComplete has something weird in it)

 

Then I'd try hardcoding a value for y: instead of having it mathematically calculated.  Seems dumb but worth a shot, might provide an insight

 

Here's a text tween example that does work, in case it helps

 

http://flashysubstance.com/phaserTextTween/

Link to comment
Share on other sites

I found the source of the problem: I had written a function to create the Text objects for me, and the reference the function returned was not tweenable for whatever reason. I replaced all uses of my function with game.add.text() and it works fine. Thanks for the debugging suggestions, they put me on the right track!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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