Lawen Posted March 12, 2015 Share Posted March 12, 2015 Hi everyone! I want to create a little shaking effect on an object. My idea is to start a tween that moves the obj to {x: obj.x-10}, yoyo that so it comes back to its original position, and once is finish, chain another tween to the other side, {x: obj.x+10}, which is also with yoyo(true).var targetVariationX = obj.x;var targetVariationY = obj.y;var shakeTween1 = game.add.tween(obj).to({x:targetVariationX - 10}, time);shakeTween1.yoyo(true); var shakeTween2 = game.add.tween(obj).to({x:targetVariationX + 10}, time);shakeTween2.yoyo(true);shakeTween1.chain(shakeTween2);shakeTween1.start();The problem comes when I try to set .repeat(#) to any of the tweens. It only repeats one of them, not the hole chained tweens. Any idea? Link to comment Share on other sites More sharing options...
BdR Posted June 27, 2015 Share Posted June 27, 2015 Not sure if you're still looking for this, but I already posted a similar shake effect using tweens in this thread and combine it with this example then you can do this:// shake it 10 pixels, 3 timesgame.add.tween(obj).to({x: targetVariationX-10}, time).to({x: targetVariationX+10}, time).repeatAll(3).start(); Link to comment Share on other sites More sharing options...
Recommended Posts