espace Posted July 24, 2016 Share Posted July 24, 2016 Hi, I have a group with different elements and i want to move this group at a position without effect. I use the position.set to hide my group at the top of my screen. Next, i call the e.transition who move my group to bottom> it works After i call the e.transitionback who move the group to the top to hiding this group > don't works The behaviour is that my group seems to be to the position.set (0,-480) so the transitionback seems to not work because it move from -480 to -480. However the previous tween move this group to the position.y=0...idon't understand. Why ? and how do you do to prevent that ? Group.position.set(0,-480) transition=game.add.tween(Group).to({x:0,y:0},700,Phaser.Easing.Elastic.Out,true,2000,false); transitionback=game.add.tween(Group).to({x:0,y:-480},4700,Phaser.Easing.Elastic.Out,true,4000,false); Link to comment Share on other sites More sharing options...
espace Posted July 25, 2016 Author Share Posted July 25, 2016 I know that there is an onComplete function but in my case i don't want that because it's the player who move uo or down the group.... Nobody? Link to comment Share on other sites More sharing options...
TickleMeElmo Posted July 25, 2016 Share Posted July 25, 2016 my question would be how does the first one even work because you're practically calling 2 tweens in the same time on the same parameters. Also if you want player to be in control then maybe you should do this: transition = function() { //tween stuff here }; this way you're not calling the tween the moment you create it. Link to comment Share on other sites More sharing options...
espace Posted July 25, 2016 Author Share Posted July 25, 2016 Thanks but I don't understand because the delay between these two tweens is different ( 4000 vs 2000) so the transitions are not on the same time....or i missing something? Link to comment Share on other sites More sharing options...
in mono Posted July 25, 2016 Share Posted July 25, 2016 You can't just throw in two different tweens and expect something logical to happen. Try chaining the second tween to the first (e.g. with tween.onComplete). Link to comment Share on other sites More sharing options...
espace Posted July 25, 2016 Author Share Posted July 25, 2016 The tweens in phaser are not asynchronous ? What i don't understand is that in phaser's example there is a case where 2 tweens are applied on the same object on the same time. http://phaser.io/examples/v2/tweens/tween-several-properties Link to comment Share on other sites More sharing options...
in mono Posted July 25, 2016 Share Posted July 25, 2016 My point is that you are trying to modify the same property using two tweens that start at the same time, which is (to me at least) guaranteed to introduce some unexpected behaviour. The example tweens two different properties and this is why it works. If you want to move something to a certain point and then back, you can pass the values you want as an array like this: game.add.tween(object) .to({x: [200, 0], y: [200, 0]}, 500, Phaser.Easing.Default, true); If the object is at (0, 0) at the start, then it will move diagonally to (200, 200) and then back to (0, 0). espace 1 Link to comment Share on other sites More sharing options...
3ddy Posted July 25, 2016 Share Posted July 25, 2016 In your case you can set yoyo effect of tween to true (last paremeter i believe) and set some yoyoDelay http://phaser.io/docs/2.4.2/Phaser.Tween.html#yoyoDelay Link to comment Share on other sites More sharing options...
espace Posted July 25, 2016 Author Share Posted July 25, 2016 hi, thanks for everyone for your solutions i have learn some tricks I understand that there is a problem to launch 2 tweens however i specify a delay time different. i test by myself this : e.transition=game.add.tween(Group).to({x:0,y:0},700,Phaser.Easing.Elastic.Out,true,2000); function nexttr(){ e.transitionback=game.add.tween(Group).to({x:0,y:-h},700,Phaser.Easing.Elastic.Out,true,1); } game.time.events.add(Phaser.Timer.SECOND * 4, nexttr, this); and it works !????? If we think about it, it's the desired behaviour of delay.....normally it's what the delay should do....for me it's really a bug in the tween function, expect if i have missing something. Before js, i have learn the lua language and i have develop some applications with corona sdk and with this framework we can use the tweens like my first post without problem. https://docs.coronalabs.com/api/library/transition/to.html Link to comment Share on other sites More sharing options...
Recommended Posts