Note that there are some explanatory texts on larger screens.

plurals
  1. POanimationArray only playing last image
    primarykey
    data
    text
    <p>I currently have this method buttonHit that calls playAnimationToNumber which accepts an int, which is then in turn used to run through a loop playing an array of images for each iteration, however it only seems to be playing the last array.. can you see why? because I am slightly lost and would appreciate the help.</p> <pre><code>//attached to button and it calls animation method. - (void)buttonHit:(id)sender{ [self playAnimationToNumber:5]; } - (void)playAnimationToNumber:(int)number{ for (int counter=1; counter&lt;=number; counter++) { NSString *imageNameForFirstNumber = [NSString stringWithFormat:@"Flap%i.png", counter]; NSArray *imagesForAnimation = [NSArray arrayWithObjects:[UIImage imageNamed:@"FlapMoving1.png"], [UIImage imageNamed:@"FlapMoving2.png"], [UIImage imageNamed:imageNameForFirstNumber], nil]; animationArray.animationImages = [[NSArray alloc] initWithArray:imagesForAnimation]; animationArray.animationDuration = 0.5; animationArray.animationRepeatCount = 1; [animationArray startAnimating]; [self.view addSubview:animationArray]; } [animationArray release]; } </code></pre> <p><strong>WORKING CODE</strong> ' - (void)playAnimationToNumber:(int)number{</p> <pre><code>NSMutableArray *imagesForAnimation = [[NSMutableArray alloc] initWithCapacity:0]; for (int counter=1; counter&lt;=number; counter++) { NSString *imageNameForFirstNumber = [NSString stringWithFormat:@"Flap%i.png", counter]; [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]]; [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving2.png"]]; [imagesForAnimation addObject:[UIImage imageNamed:imageNameForFirstNumber]]; } animationArray.animationImages = [NSArray arrayWithArray:imagesForAnimation]; animationArray.animationDuration = 5.9; animationArray.animationRepeatCount = 1; [animationArray startAnimating]; [self.view addSubview:animationArray]; [imagesForAnimation release]; </code></pre> <p>}'</p>
    singulars
    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.
    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