Hello guys.
I'm trying to build a memory game. The kind where you turn 2 peaces and have to match 2 images hidden bellow them.
The peaces (buttons) that match have the same tag.
Everything seams to be working well, but there's a small bug when i run the code in the simulator.
- When i press the first peace of the set it always takes 0.5 sec. to fade out
- When i press the second peace, and there's a match between the first one, it also takes 0.5 sec. to fade out
- The problem is when i press the second peace, and there's no match between them... it doesn't fade out! Simply disappears (it should take 0.5 sec. to fade out) and then both peaces fade back in 0.5 sec.
Code:
- (IBAction)pressGO: (id) sender {
if (pushCTRL == 0) {
pushCTRL = 1;
idTAG01 = [sender tag];
BTN01 = sender;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[sender setAlpha:0];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
else if (pushCTRL == 1) {
pushCTRL = 0;
idTAG02 = [sender tag];
BTN02 = sender;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0];
[UIView setAnimationDuration:0.5];
[sender setAlpha:0];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
if (idTAG02 != idTAG01) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.5];
[UIView setAnimationDuration:0.5];
BTN01.alpha = 1;
BTN02.alpha = 1;
[UIView setAnimationDelay:0.5];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
}
}