Jump to content

GSAP onComplete & Phaser


Mike018
 Share

Recommended Posts

GSAP works great with Phaser, but I haven't figured out how to use Phaser specific things in a GSAP onComplete function. Here's an example. I can't create a sprite via an onComplete function because it uses something specific to Phaser. At least I think that's the problem, but I can tween something using this.game.world.centerX and other Phaser position parameters. This example gives me this error: Cannot read property 'add' of undefined. Any ideas?

TweenMax.to(this.object, 1, {x:"+=20", onComplete: this.testFunction})

testFunction() {

this.game.add.sprite(
      this.game.world.centerX,
      this.game.world.centerY,
      'object5'
    );

}

 

Link to comment
Share on other sites

You mean something like this? This is what I use for a few of my windows in my game.

var tween;
var destination = 400;
var duration = 500

tween = this.game.add.tween(this).to( { y: destination }, duration, Phaser.Easing.Linear.None, true);

tween.onStart.add(function () {
	// Add stuff
}, this);

tween.onComplete.add(function () {
	// Add stuff
}, this);
Link to comment
Share on other sites

1 hour ago, LTNGames said:

You mean something like this? This is what I use for a few of my windows in my game.


var tween;
var destination = 400;
var duration = 500

tween = this.game.add.tween(this).to( { y: destination }, duration, Phaser.Easing.Linear.None, true);

tween.onStart.add(function () {
	// Add stuff
}, this);

tween.onComplete.add(function () {
	// Add stuff
}, this);

That's using the Phaser tween engine. My question is regarding the GSAP animation library.

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...