Multiple Animations with UIImageView

Discussion in 'iPhone/iPad Programming' started by JavaWizKid, Oct 28, 2009.

  1. macrumors 6502a

    Joined:
    Sep 18, 2008
    Messages:
    572
    #1
    I'm having a bit of difficulty loading multiple animations in my viewDidLoad function.

    Code:
    - (void)viewDidLoad {
    [super viewDidLoad];
    spaceship.animationImages=[NSArray arrayWithObjects: [UIImage imageNamed: @"spaceship.png"], [UIImage imageNamed: @"spaceship1.png"], nil];
    	[spaceship setAnimationRepeatCount:1e100f];
    	spaceship.animationDuration = 0.15;
    	[spaceship startAnimating];
    	
    	spaceship1.animationImages=[NSArray arrayWithObjects: [UIImage imageNamed: @"explode1.png"], 
    							   [UIImage imageNamed: @"explode2.png"], 
    							   [UIImage imageNamed: @"explode3.png"], 
    							   [UIImage imageNamed: @"explode4.png"], 
    							   [UIImage imageNamed: @"explode5.png"], 
    							   [UIImage imageNamed: @"explode6.png"], 
    							   [UIImage imageNamed: @"explode7.png"], 
    							   [UIImage imageNamed: @"explode8.png"], 
    							   [UIImage imageNamed: @"explode9.png"], 
    							   [UIImage imageNamed: @"explode10.png"], 
    							   [UIImage imageNamed: @"explode1.1png"], 
    							   [UIImage imageNamed: @"explode12.png"], 
    							   [UIImage imageNamed: @"explode13.png"], 
    							   [UIImage imageNamed: @"explode14.png"], 
    							   [UIImage imageNamed: @"explode15.png"], 
    							   [UIImage imageNamed: @"explode16.png"], 
    							   [UIImage imageNamed: @"explode17.png"], 
    							   [UIImage imageNamed: @"explode18.png"], 
    							   [UIImage imageNamed: @"explode19.png"], 
    							   [UIImage imageNamed: @"explode20.png"], 
    							   [UIImage imageNamed: @"explode21.png"], 
    							   [UIImage imageNamed: @"explode22.png"], nil];
    	[spaceship1 setAnimationRepeatCount:1];
    	spaceship1.animationDuration = 0.5;
    }
    Basically the spaceship and spaceship1 are UIImageViews linked in Interface Builder to the same image. The spaceship.png and spaceship1.png wont animate when the explode.png animation is present in the viewDidLoad function. If I remove the explode.png animation, the spaceship, spaceship1.png animation works fine. The explode animation is started using [spaceship1 startAnimating]; in another part of the code and it runs the animation correctly. How can I get both these animations to load on the single UIImageView? Thanks.
     

Share This Page