valueerror Posted September 12, 2014 Share Posted September 12, 2014 is this indendet? is this a bug or a way around this? i am using timeouts now in the exact same duration as the tweenbut using the tween.onComplete function would be more convenient. Link to comment Share on other sites More sharing options...
BlueGreen Posted September 12, 2014 Share Posted September 12, 2014 Try:Tween._lastChild.onComplete.add(...); Link to comment Share on other sites More sharing options...
Steve Kane Posted September 13, 2014 Share Posted September 13, 2014 Try naming your tweens and attaching handlers to the desired tween. Here is some super psuedocode var up = tweenvar down = tween down.onComplete.add(function () {}) up.chain(down).start() There is an example of doing exactly this here in a little quick multiplayer game prototype I was developing in ES6 a few months ago: https://github.com/stevekane/lttp/blob/master/public/entities/Player.js lines 37 - 60 Hope this helps. Steve Link to comment Share on other sites More sharing options...
valueerror Posted September 17, 2014 Author Share Posted September 17, 2014 thank you both.. i just tried the _lastCchild way and it seems to work.. one question though.. why does it work? where comes this lastChild method from.. is this something phaser does or a plain javascript method ? Link to comment Share on other sites More sharing options...
valueerror Posted September 17, 2014 Author Share Posted September 17, 2014 well.. this works ! it starts the onComplete function i want at the end of the second tween.. but... there's always a but.. the function is triggered twice.. once for every tween in the row... this _lastChild method solved the problem with the tween starting after the first part of the tween .. but this seems to be another problem... Link to comment Share on other sites More sharing options...
valueerror Posted September 17, 2014 Author Share Posted September 17, 2014 ok... because adding onComplete on chained tweens sucks ;-) (it either adds the function to the first tween in the chain instead of the last and/or adds it to both or something else i don't understandi used the second approach steve kane proposed.. this works like charm and is actually a very beautiful solution for my case.. so this is the code that works : var ascent = game.add.tween(body.sprite.scale).to({x:max,y:max}, upTime, Phaser.Easing.Sinusoidal.Out) var descent = game.add.tween(body.sprite.scale).to({x:originalScale,y:originalScale}, downTime, Phaser.Easing.Sinusoidal.In) descent.onComplete.add(function(){ checkHitLandig(body); }); ascent.chain(descent).start();thx again.. do you think this is a bug? Link to comment Share on other sites More sharing options...
Recommended Posts