Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-09-2010, 01:42 AM   #1 (permalink)
SaturdayNightLive
Registered Member
 
Join Date: Feb 2010
Posts: 1
Default Pushing around a uiimageview with a uiimageview

In my app I have a uiimageview of a guy. i also have a uiimageview of ball. I want to make it so if the guy runs into the ball he "pushes" it. How can this be done?
my code for moving the guy is as follows:
Code:
-(IBAction)downRight {
	[self moveRight];
	guyImageView.image = [UIImage imageNamed:@"guy_right.png"]; //right facing image
	timerRight = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveRight) userInfo:nil repeats:YES];	
}

-(IBAction)downLeft {
	[self moveLeft];

guyImageView.image = [UIImage imageNamed:@"guy_left.png"]; //left facing image
	timerLeft = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveLeft) userInfo:nil repeats:YES];	
}
-(IBAction)downDown {
	
	
		guyImageView.image = [UIImage imageNamed:@"guy_down.png"]; //left facing image

	
	[self moveDown];

	timerDown = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveDown) userInfo:nil repeats:YES];	
}
-(IBAction)downUp {
		guyImageView.image = [UIImage imageNamed:@"guy_up.png"]; //left facing image
	
		[self moveUp];

	timerUp = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveUp) userInfo:nil repeats:YES];	
}

-(IBAction)upRight {
	if (timerRight != nil) 
	{
		[timerRight invalidate];
		timerRight = nil;
		[self stationaryGuy];

	}	
	
}
-(IBAction)upDown {
	
	if (timerDown != nil) 
	{
		[timerDown invalidate];
		timerDown = nil;
		[self stationaryGuy];

	}	
	
}
-(IBAction)upUp {
	
	if (timerUp != nil) 
	{
		[timerUp invalidate];
		timerUp = nil;
		[self stationaryGuy];

	}	
	
}

-(IBAction)upLeft {
	
	if (timerLeft != nil) {
		[timerLeft invalidate];
		timerLeft = nil;
		[self stationaryGuy];

    }
	
}

-(void)moveRight {

	guyImageView.frame = CGRectMake(guyImageView.frame.origin.x+HorizontalSquareSize, guyImageView.frame.origin.y, guyImageView.frame.size.width, guyImageView.frame.size.height);	
	[self checkForBoundry];

}
-(void)moveLeft {

	guyImageView.frame = CGRectMake(guyImageView.frame.origin.x-HorizontalSquareSize, guyImageView.frame.origin.y, guyImageView.frame.size.width, guyImageView.frame.size.height);	
	[self checkForBoundry];

}
-(void)moveUp {

	guyImageView.frame = CGRectMake(guyImageView.frame.origin.x, guyImageView.frame.origin.y-VerticalSquareSize, guyImageView.frame.size.width, guyImageView.frame.size.height);	
	[self checkForBoundry];

	
}
-(void)moveDown {

		guyImageView.frame = CGRectMake(guyImageView.frame.origin.x, guyImageView.frame.origin.y+VerticalSquareSize, guyImageView.frame.size.width, guyImageView.frame.size.height);	
	[self checkForBoundry];
}
P.S. if your looking for Touch and Hold in buttons, its in my code!


Thanks to anyone who can assist me.
SaturdayNightLive is offline   Reply With Quote
 

» Advertisements
» Online Users: 882
22 members and 860 guests
ADY, anshuk1219, chits12345, dabvid, donlucacorleone, dreamer11, FAED, gmarro, Grinarn, honeybutterfly, ilmman, IQ8Y1, john love, leahov, M@realobjects, Nicoloren, nobre84, R40ul, RoryHarvey, sethaver, snackbox, VikMyr
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,866
Threads: 89,225
Posts: 380,691
Top Poster: BrianSlick (7,129)
Welcome to our newest member, sethaver
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:12 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.