Ninjadoodle Posted May 28, 2015 Share Posted May 28, 2015 Hi guys I have 6 cards which I turn with a tween by using a for loop. I want to change the texture of the card when tween1 is finished, but I'm having trouble passing the right parameter.for (i=0; i<sprites.length; i++) { sprites[i].mousedown = sprites[i].touchstart = itemTouch; var flipCard = function(num) { sprites[num].setTexture('card0004'); } var cardTurn1 = new game.Tween(sprites[i].scale) .to({x:0.1}, 250) .delay(500) var cardTurn2 = new game.Tween(sprites[i].scale) .to({x:1}, 250) .onComplete(flipCard(i)) cardTurn1.chain(cardTurn2); cardTurn1.start();} If anybody could help me here, that would be awesome! Thank you in advance! Quote Link to comment Share on other sites More sharing options...
enpu Posted May 28, 2015 Share Posted May 28, 2015 for (i=0; i<sprites.length; i++) { sprites.mousedown = sprites.touchstart = itemTouch; sprites.flipCard = function() { this.setTexture('card0004'); } var cardTurn1 = new game.Tween(sprites.scale) .to({x:0.1}, 250) .delay(500) var cardTurn2 = new game.Tween(sprites.scale) .to({x:1}, 250) .onComplete(sprites.flipCard.bind(sprites)); cardTurn1.chain(cardTurn2); cardTurn1.start(); } Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted May 28, 2015 Author Share Posted May 28, 2015 Hi @enpu You're a legend! Thanks heaps Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.