summary refs log tree commit diff stats
path: root/Classes/JumpGameMode.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-05 00:30:05 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-05 00:30:05 -0400
commitf39ff64d51952d8af896daf8b556178abc01d47a (patch)
tree59ca21f2de3ccf4a5d5c25d8c70ea55251362b8c /Classes/JumpGameMode.m
parentd279ad58f35364adf3b38dd0de82aa4848a69390 (diff)
downloadcartcollect-f39ff64d51952d8af896daf8b556178abc01d47a.tar.gz
cartcollect-f39ff64d51952d8af896daf8b556178abc01d47a.tar.bz2
cartcollect-f39ff64d51952d8af896daf8b556178abc01d47a.zip
Fixed jumping while paused in Jump mode
Refs #204 and fixes #214
Diffstat (limited to 'Classes/JumpGameMode.m')
-rw-r--r--Classes/JumpGameMode.m32
1 files changed, 22 insertions, 10 deletions
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index f03eae0..79c87bc 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -189,24 +189,36 @@
189 189
190- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 190- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
191{ 191{
192 UITouch* touch = [touches anyObject]; 192 if ((!isPaused) && (!isGesturing))
193 gestureStartPoint = [touch locationInView:nil]; 193 {
194 UITouch* touch = [touches anyObject];
195 gestureStartPoint = [touch locationInView:nil];
196 isGesturing = YES;
197 }
194} 198}
195 199
196- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 200- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
197{ 201{
198 UITouch* touch = [touches anyObject]; 202 if (isGesturing)
199 CGPoint gestureCurrentPosition = [touch locationInView:nil];
200 CGFloat angle = atan2f(gestureCurrentPosition.y - gestureStartPoint.y, gestureCurrentPosition.x - gestureStartPoint.x);
201 CGFloat distance = sqrt(powf((gestureCurrentPosition.x - gestureStartPoint.x),2) + powf((gestureCurrentPosition.y - gestureStartPoint.y),2));
202
203 if ((distance >= kMinimumGestureLength) && (angle >= expectedAngle - M_PI_4) && (angle <= expectedAngle + M_PI_4) && ((cart.sprite.position.y >= 80) && (cart.sprite.position.y <= 90)))
204 { 203 {
205 jump = YES; 204 UITouch* touch = [touches anyObject];
206 cart.falling = NO; 205 CGPoint gestureCurrentPosition = [touch locationInView:nil];
206 CGFloat angle = atan2f(gestureCurrentPosition.y - gestureStartPoint.y, gestureCurrentPosition.x - gestureStartPoint.x);
207 CGFloat distance = sqrt(powf((gestureCurrentPosition.x - gestureStartPoint.x),2) + powf((gestureCurrentPosition.y - gestureStartPoint.y),2));
208
209 if ((distance >= kMinimumGestureLength) && (angle >= expectedAngle - M_PI_4) && (angle <= expectedAngle + M_PI_4) && ((cart.sprite.position.y >= 80) && (cart.sprite.position.y <= 90)))
210 {
211 jump = YES;
212 cart.falling = NO;
213 }
207 } 214 }
208} 215}
209 216
217- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
218{
219 isGesturing = NO;
220}
221
210- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration 222- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
211{ 223{
212 [super accelerometer:accelerometer didAccelerate:acceleration]; 224 [super accelerometer:accelerometer didAccelerate:acceleration];