Animating an Image
I m creating a game, in that i want to use some animation, but i m new to animations. I want to create an image ,as soon as i click on imageview, the image should come in bouncing manner as if it is a Ball, so is it possible to do so??? The image is predefined fo开发者_C百科r the game.and it must come after touch begin event occures, can any one help me??? regards viral.
you can do something like
imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
[self.view addSubview:imageview];
imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y), imageview.frame.size.width, imageview.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
//[UIView setAnimationWillStartSelector:@selector(Transform2)];
[UIView setAnimationDuration:k_AnimateTime];
[UIView setAnimationBeginsFromCurrentState:YES];
//[UIView setAnimationDidStopSelector:@selector(increaseCount)];
imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
[UIView commitAnimations];
this will move your image from one co coordinate to another coordinate animating... set appropriate coordinate to make it looks like bouncing effcet...
精彩评论