AlgoGames Posted April 22, 2017 Share Posted April 22, 2017 I am using RESIZE mode and have a few tweens which move from one point to another. The moment I resize the game, I need to recalculate the new x/y target for the sprites and update the tweens otherwise sprites keep moving to the previous target location which is incorrect for new size of the game. I looked into updateTweenData method but could not achieve what I want to do. I have tried to pause the tweens in resize method and directly change properties' x/y (tween.properties.x, tween.properties.y) but it does not change anything and tweens keep moving to previous target location after I resume. Changing x/y using something like updateTweenData ("x", newValue) also makes no difference. Does anyone know if this is supported and is possible to achieve? Link to comment Share on other sites More sharing options...
samid737 Posted April 22, 2017 Share Posted April 22, 2017 Hi, there is a timeline property for a tween, if you inspect it you will find many properties that you can tweak to achieve what you want: http://phaser.io/docs/2.4.4/Phaser.Tween.html#timeline For your case, here is an example of how you can update the tween during play: You could easily adapt it to your scale ratio. Note that you also have to recalculate your new duration,otherwise it will run sort of fast forward to the new position. Also the tweenCondition I provided is position changing, but you can specify what you want to achieve (alpha change, scale change etcc)... Link to comment Share on other sites More sharing options...
AlgoGames Posted April 22, 2017 Author Share Posted April 22, 2017 3 hours ago, samid737 said: Hi, there is a timeline property for a tween, if you inspect it you will find many properties that you can tweak to achieve what you want: http://phaser.io/docs/2.4.4/Phaser.Tween.html#timeline For your case, here is an example of how you can update the tween during play: You could easily adapt it to your scale ratio. Note that you also have to recalculate your new duration,otherwise it will run sort of fast forward to the new position. Also the tweenCondition I provided is position changing, but you can specify what you want to achieve (alpha change, scale change etcc)... Perfect. Exactly what I was looking for. Thanks much. Let me try this now. samid737 1 Link to comment Share on other sites More sharing options...
samme Posted April 22, 2017 Share Posted April 22, 2017 Another method is tween.isPaused = tween.isRunning = false; tween.timeline.length = 0; tween.to(/*…*/).start(); Link to comment Share on other sites More sharing options...
AlgoGames Posted May 2, 2017 Author Share Posted May 2, 2017 The method specified by samid737 works perfectly. samme, I am not sure how to use your method. The last line tween.to() would need to specify new x,y coordinates which I think is not allowed once tween has started. Am I missing something here? Link to comment Share on other sites More sharing options...
Recommended Posts