views:

23

answers:

0

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];
}

}