Question

In my project, I have to create a game with 12 cards. At the begining of the game, all of them are face-down. If I chose one card, it will face-up. And if I continue to choose another card, if the images of both of 2 cards that are face-up is the same, the cards will disapear. If not, the cards will turn face-down again.

I am coding with Android 2.2 and I using this example about fipping animation: android-animaions-3d-flip

But I got a stuck, when I choose a card, and after that, I continue choose another one, if they are the same, both of them are disapear. This case works correctly. But if they are different, the second card is even not face-up. I think the problem may be about starting 2 animations together at the same time. Following is my code for the case when two cards are different:

 Flip3dAnimation rotation1 = new Flip3dAnimation(0, -90, centerX1, centerY1);
 rotation1.setDuration(250);
 rotation1.setFillAfter(true);
 rotation1.setInterpolator(new AccelerateInterpolator());
 rotation1.setAnimationListener(new DisplayNextView(isFirstImage[flipRid.get(0).x*3 +                 flipRid.get(0).y ], image11, image12 ));
                            image12.startAnimation(rotation1);

 Flip3dAnimation rotation2 = new Flip3dAnimation(0, -90, centerX2, centerY2); 
 rotation2.setDuration(250);
 rotation2.setFillAfter(true);
 rotation2.setInterpolator(new AccelerateInterpolator());
 rotation2.setAnimationListener(new DisplayNextView(isFirstImage[flipRid.get(1).x*3 + flipRid.get(1).y ], image21, image22 ));

 image12.startAnimation(rotation1); // First card works
 image22.startAnimation(rotation2); // Second card not work correctly

Please help me, thank you.

Était-ce utile?

La solution

use this example and combine your 3d flip animation example with this and then your problem is resolved.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top