 |
 |
|
 |
02-09-2010, 12:42 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 1
|
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.
|
|
|
02-09-2010, 12:47 PM
|
#2 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 10
|
Im interested in this too. did you figure it out?
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 391 |
| 44 members and 347 guests |
| bryhardt, CHV, cmezak, DaveM, dkern, Dorald, Elegy, funkyspider, gandohr, Gi-lo, goodcode, gpacheco, gshaviv, hcarsten, HemiMG, iGeorG, JasonR, johnlikesit, JonnyBGoode, KennyChong, Kilby, Meoz, miguel.campiao, mikeyb, mobilesoftware, Mopedhead, Mr Jack, mr.pagu, MrMattMac, msudan, m_kaminsky@yahoo.com, nhdzung, Nuncha, prathumca, Seaturkey74, snowboarderz69, SPAS, Tambourin, tensaix2j, thadre, ToM, tychop, Varras |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,293
Threads: 39,081
Posts: 171,364
Top Poster: smasher (2,575)
|
| Welcome to our newest member, michael@2label |
|