Jump to content

tween position.set problem


espace
 Share

Recommended Posts

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

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

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).

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

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