christian.tucker Posted December 9, 2014 Share Posted December 9, 2014 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 definedI followed this thread to get the callbacks - http://www.html5gamedevs.com/topic/1651-tween-oncompletecallback/ Here's my codePlayer.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 thenfunction 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 More sharing options...
Taleforge Posted December 9, 2014 Share Posted December 9, 2014 On wich line is the error happening?What phaser version are you using? Link to comment Share on other sites More sharing options...
christian.tucker Posted December 9, 2014 Author Share Posted December 9, 2014 On wich line is the error happening?What phaser version are you using? I'm using phaser vs 1.5, however after restarting my computer the error seemed to have resolved itself. Currently my biggest problem is passing a parameter through to the event. Link to comment Share on other sites More sharing options...
valueerror Posted December 9, 2014 Share Posted December 9, 2014 you could use "this" instead of:onComplete.add(combatMoveBack, this);you should be able to use:onComplete.add(combatMoveBack, myvalue);and in the function combatMoveBack: mypassedparameter = this;btw. you can mark a thread solves as threadstarter in your first post Link to comment Share on other sites More sharing options...
Recommended Posts