From fa4edf3e32077243ec9af3f087771d52b1530643 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 12 Jun 2013 20:56:24 -0600 Subject: move ball to a random location when touched --- .../mo.xcuserdatad/UserInterfaceState.xcuserstate | Bin 16144 -> 16229 bytes .../xcdebugger/Breakpoints.xcbkptlist | 46 ++++++++++ Wobble/ViewController.m | 16 +++- Wobble/en.lproj/ViewController.xib | 97 ++++++++++----------- 4 files changed, 109 insertions(+), 50 deletions(-) create mode 100644 Wobble.xcodeproj/xcuserdata/mo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist diff --git a/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate b/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate index c8e7b3d..4853b19 100644 Binary files a/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate and b/Wobble.xcodeproj/project.xcworkspace/xcuserdata/mo.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Wobble.xcodeproj/xcuserdata/mo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/Wobble.xcodeproj/xcuserdata/mo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 0000000..cc6c8cb --- /dev/null +++ b/Wobble.xcodeproj/xcuserdata/mo.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,46 @@ + + + + + + + + + + + diff --git a/Wobble/ViewController.m b/Wobble/ViewController.m index 0a793ae..f24f61a 100644 --- a/Wobble/ViewController.m +++ b/Wobble/ViewController.m @@ -2,7 +2,7 @@ #import "Ball.h" @interface ViewController () -@property int score; + @property int score; @end @implementation ViewController @@ -15,10 +15,24 @@ -(void)onTouch:(UIGestureRecognizer *)sender { + [self moveBallToRandomLocation]; self.score += 2; self.scoreLabel.text = [NSString stringWithFormat:@"%d", self.score]; } +- (void)moveBallToRandomLocation +{ + [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^ + { + CGPoint newLocation = self.ball.center; + newLocation.y = (float)random() / RAND_MAX * 940 + 32; + newLocation.x = (float)random() / RAND_MAX * 704 + 32; + NSLog(@"Moving to %f %f", newLocation.x, newLocation.y); + self.ball.center = newLocation; + } completion:^(BOOL b) { + }]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; diff --git a/Wobble/en.lproj/ViewController.xib b/Wobble/en.lproj/ViewController.xib index a9afd99..89348e1 100644 --- a/Wobble/en.lproj/ViewController.xib +++ b/Wobble/en.lproj/ViewController.xib @@ -36,27 +36,26 @@ 274 - + 274 {{347, 464}, {75, 75}} - _NS:9 - + 1 MCAwIDAAA IBIPadFramework - + 292 {{363, 20}, {42, 21}} - + _NS:9 NO YES @@ -89,8 +88,8 @@ {{0, 20}, {768, 1004}} - - + + 2 @@ -109,19 +108,19 @@ - ball + scoreLabel - + - 20 + 31 - scoreLabel + ball - + - 31 + 32 @@ -147,11 +146,11 @@ 2 - - + + 9 0 - + 9 1 @@ -163,8 +162,8 @@ 24 2 - - + + 5 0 @@ -179,8 +178,8 @@ 9 3 - - + + 9 0 @@ -195,8 +194,8 @@ 22 2 - - + + 3 0 @@ -211,11 +210,11 @@ 9 3 - + 4 0 - + 4 1 @@ -227,8 +226,8 @@ 9 3 - - + + 3 0 @@ -243,37 +242,37 @@ 29 3 - - + + 9 - + 16 - + 17 - + 18 - + 21 - + - - + + 7 0 @@ -283,7 +282,7 @@ 42 1000 - + 3 9 1 @@ -293,23 +292,23 @@ 23 - + 25 - + 26 - + 30 - - + + @@ -323,16 +322,16 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - - - - + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - + com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -347,7 +346,7 @@ - 31 + 32 -- cgit v1.2.3