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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-09-2010, 01:42 AM   #1 (permalink)
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
Old 02-09-2010, 01:47 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 15
Default

Im interested in this too. did you figure it out?
TheAppByte is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 576
17 members and 559 guests
Arfan, BrianSlick, dacapo, devangvyas, Duncan C, Hito_kun, learningtocode, linkmx, LiquidFire, MarcoAlmeida, mollysalomons, Monstertaco, oceanlablight, Rudy, soonw29, sudama, Vineesh
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,773
Threads: 89,203
Posts: 380,584
Top Poster: BrianSlick (7,129)
Welcome to our newest member, holisticni8
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:38 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0