Animation not playing

Posted by Tate Allen on Stack Overflow See other posts from Stack Overflow or by Tate Allen
Published on 2010-05-30T21:16:11Z Indexed on 2010/05/30 21:22 UTC
Read the original article Hit count: 334

Filed under:
|
|
|
|

Hello again, I didn't say this last time but I am relatively new to iPhone programming and extremely new to iPhone game development so bear with me. In my game, when I tilt the device, the character moves and faces the correct direction, but does not animate. I am using an animated UIImageView. Here is the code:

float newX = character.center.x + (accel.x * 12); if (newX > 30 && newX < 290) character.center = CGPointMake(newX, character.center.y); if (accel.x < 0) { NSArray *imgArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"run3left.png"], [UIImage imageNamed:@"run1left.png"], [UIImage imageNamed:@"run2left.png"], [UIImage imageNamed:@"run1left.png"], nil];

character.animationImages = imgArray;
character.animationDuration = 0.5;
character.contentMode = UIViewContentModeBottomLeft;
[self.view addSubview:character];
[character startAnimating];
}

if (accel.x > 0) {
    NSArray *imgArray = [[NSArray alloc] initWithObjects:
                         [UIImage imageNamed:@"run3.png"],
                         [UIImage imageNamed:@"run1.png"],
                         [UIImage imageNamed:@"run2.png"],
                         [UIImage imageNamed:@"run1.png"],
                         nil];

    character.animationImages = imgArray;
    character.animationDuration = 0.5;
    character.contentMode = UIViewContentModeBottomLeft;
    [self.view addSubview:character];
    [character startAnimating];
}

}

© Stack Overflow or respective owner

Related posts about image

Related posts about animation