Okay so here's my problem: i want a moving character thats slightly animated, so i came up with a character that uses simple coding and only two images- 1. the image for that character 2. the outline for the object. I used separate images because I want the image to rotate, so the frame might hit an object be4 the users see it to do so, and i couldn't be bothered to create a circular frame. How i'm making him rotate is using a timer, and two actions. Action 1 ("left") is attached to the image of the character via "Touch Down", so it reacts whilst the buttons being pushed. The other ("leftNo") is connected to the same image, via "Touch up inside" and "Touch drag exit". The problem is when i run it, it the timer only runs once? Here's my code:
-(IBAction)start {
direction = 0;
moveHorizontally = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveHorizon) userInfo:nil repeats:YES];
[self addSubview:PlayScreen];
}
-(IBAction)left {
direction = 1;
}
-(IBAction)leftNo {
direction = 0;
}
-(void)moveHorizon {
if(direction == 1) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.01];
playerImage.transform = CGAffineTransformMakeRotation(0.5);
[UIView commitAnimations];
direction = 1;
}
}
Please help me...