Note that there are some explanatory texts on larger screens.

plurals
  1. POmake animation wait for 1 sec – Objective-c
    primarykey
    data
    text
    <p>I'm working on a memory game with 6 UIButtons that changes background-image when they're touched. I check if two of the taped ones are the same with booleans. I have 6 different and each set to YES in each button action. </p> <p>If first BOOL not is equal to second BOOL then they should change back to their original background-image. My problem is that when the second button is clicked, directly, the two buttons changes. I want the second button's image to be seen before they change. This is my code: </p> <pre><code>- (void)buttonClicked:(id)sender { buttonClickedBOOL = YES; [animation stuff....] if (randomNumberi == 0) { [button setBackgroundImage:[UIImage imageNamed:@"apple.png"] forState:UIControlStateNormal]; } else if (randomNumberi == 1) { [button setBackgroundImage:[UIImage imageNamed:@"windows_logo.png"] forState:UIControlStateNormal]; } else if (randomNumberi == 2) { [button setBackgroundImage:[UIImage imageNamed:@"fujitsu.png"] forState:UIControlStateNormal]; } [UIView commitAnimations]; [self gameCheck]; } </code></pre> <p>This is where I check the conditions:</p> <pre><code>- (void)gameCheck { if ((buttonClickedBOOL == YES) &amp;&amp; (button2ClickedBOOL == YES)) { button.enabled = NO; button2.enabled = NO; button3.enabled = NO; button4.enabled = NO; button5.enabled = NO; button6.enabled = NO; if (randomNumberi == randomNumberi2) { NSLog(@"The same"); } else { [animations stuff....] [button setBackgroundImage:nil forState:UIControlStateNormal]; [UIView commitAnimations]; [animations stuff....] [button2 setBackgroundImage:nil forState:UIControlStateNormal]; [UIView commitAnimations]; } } </code></pre> <p>The random variables are set in viewDidLoad to int numbers 0-3 and represents which images which should be set.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload