Jump to content

[Solved]Tween 'onComplete' -> add is not defined


christian.tucker
 Share

Recommended Posts

I'm trying to basically create a patrol type system, meaning that once my object tweens from A to B, I'll need him to tween from B to A, for all of eternity.

 

This is fine and all, and should be quite simple to do with the tween callback, however I'm receiving this error:

 Uncaught ReferenceError: add is not defined

I followed this thread to get the callbacks - http://www.html5gamedevs.com/topic/1651-tween-oncompletecallback/

 

Here's my code

Player.prototype.attack = function(target) {//this.playerSprite.rotation = game.physics.arcade.moveToXY(this.playerSprite, target.getX(), target.getY(), 0, 3000);//game.time.events.add(Phaser.Timer.SECOND * 3, combatMoveBack, this);var movementTween = game.add.tween(this.playerSprite.body).to( { x: target.getX() + ((this.team == 1) ? -30 : 30), y: target.getY() }, 3000, Phaser.Easing.Linear.None, true);movementTween.onComplete.add(combatMoveBack, this);this.playerSprite.animations.play('walk');};

And then

function combatMoveBack() {var movementTween = game.add.tween(this.playerSprite.body).to( { x: this.homeTile.getX(), y: this.homeTile.getY() }, 3000, Phaser.Easing.Linear.None, true);movementTween.onComplete.add(combatStop, this);this.playerSprite.animations.play('walk');}

Not sure what the issue is, 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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