Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Drop_AnimationViewController.m
- // Drop Animation
- //
- // Created by Prasanth on 1/11/10.
- // Copyright __MyCompanyName__ 2010. All rights reserved.
- //
- #import "Drop_AnimationViewController.h"
- @implementation Drop_AnimationViewController
- - (void)checkCollison {
- CGRect beginFrame1 = hole.frame;
- beginFrame1.origin = CGPointMake(0, 332);
- hole.frame = beginFrame1;
- if (CGRectContainsRect(hole.frame, fallingImage.frame)) {
- hole.hidden = YES;
- }
- }
- /*
- // The designated initializer. Override to perform setup that is required before the view is loaded.
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
- // Custom initialization
- }
- return self;
- }
- */
- /*
- // Implement loadView to create a view hierarchy programmatically, without using a nib.
- - (void)loadView {
- }
- */
- - (void)makeImageFall {
- CGRect beginFrame = fallingImage.frame;
- beginFrame.origin = CGPointMake(160,-40);
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:0.01];
- fallingImage.frame = beginFrame;
- [UIView commitAnimations];
- CGRect beginFrame1 = hole.frame;
- beginFrame1.origin = CGPointMake(0, 332);
- hole.frame = beginFrame1;
- xPoint = arc4random() % 320 + 1;
- NSLog(@"xPoint:%i", xPoint);
- CGRect frame = fallingImage.frame;
- frame.origin = CGPointMake(xPoint,480);
- [UIView beginAnimations:nil context:nil];
- [UIView setAnimationDuration:3];
- fallingImage.frame = frame;
- [UIView commitAnimations];
- if (CGRectContainsRect(hole.frame, fallingImage.frame)) {
- hole.hidden = YES;
- }
- [self checkCollison];
- }
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self makeImageFall];
- [self checkCollison];
- [NSTimer scheduledTimerWithTimeInterval:2.5 target:self selector:@selector(makeImageFall) userInfo:nil repeats:YES];
- }
- /*
- // Override to allow orientations other than the default portrait orientation.
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
- // Return YES for supported orientations
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- */
- - (void)didReceiveMemoryWarning {
- [NSTimer release];
- [hole release];
- [fallingImage release];
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
- }
- - (void)viewDidUnload {
- [NSTimer release];
- [hole release];
- [fallingImage release];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- }
- - (void)dealloc {
- [NSTimer release];
- [hole release];
- [fallingImage release];
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment