Jump to content

Could someone please help me with the logic here?


Ninjadoodle
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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();

}

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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