totallybueno Posted February 25, 2014 Share Posted February 25, 2014 Hi there, I´m having some problems with tweens in my game... I have this code:function doTween(object, property, value, delay, callback){ delay = typeof delay !== 'undefined' ? delay : 0; callback = typeof callback !== 'undefined' ? callback : null; var tween = game.add.tween(object); if(property=="x"){ tween.to({x: value}, 500).easing(Phaser.Easing.Bounce.Out).delay(delay).onCompleteCallback(callback); }else if(property=="y"){ tween.to({y: value}, 500).easing(Phaser.Easing.Bounce.Out).delay(delay).onCompleteCallback(callback); } tween.start(); }And that stuff is giving me this error on Firefox: TypeError: tween.to(...).easing(...).delay(...).onCompleteCallback is not a function Can someone explain me why? I don´t understand what´s happening... btw, I´m using Phaser v1.1.6 Thanks in advance guys. Link to comment Share on other sites More sharing options...
lessmilk Posted February 25, 2014 Share Posted February 25, 2014 The syntax for a tween callback is: tween.onComplete.add(callBack, this); totallybueno 1 Link to comment Share on other sites More sharing options...
totallybueno Posted February 25, 2014 Author Share Posted February 25, 2014 Thanks lessmilk_, I fixed that Now, another question but I guess this is purely javascript, I´m receiving an error telling me that the parameter should be a function, and I´m receiving that function (or null) as a parameter, how should I write that line? This one I have is not working... but I guess it´s just about js syntax.function doTween(object, property, value, delay, callback){//code// tween.to({x: value}, 500).easing(Phaser.Easing.Bounce.Out).delay(delay).onComplete.add(callback);} Link to comment Share on other sites More sharing options...
richpixel Posted February 26, 2014 Share Posted February 26, 2014 Maybetween.to({x: value}, 500).easing(Phaser.Easing.Bounce.Out).delay(delay);if (callback) { tween.onComplete.add(callback);} totallybueno 1 Link to comment Share on other sites More sharing options...
totallybueno Posted February 26, 2014 Author Share Posted February 26, 2014 Thanks richpixel, problem solved Link to comment Share on other sites More sharing options...
Recommended Posts