summary refs log tree commit diff stats
path: root/Classes/Cart.m
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-10 14:33:27 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-10 14:33:27 -0400
commit5ccc4fc305f502a552b1ac7e815e576c93a8159a (patch)
tree5bf4ede55160769ab74ffde1488f5382ed3ba93f /Classes/Cart.m
parentf7ce2c458df032f65c4c1eb31cf705bb284a3ee7 (diff)
downloadcartcollect-aaeea0801f05cf199f27a5f6db25576d80cb403e.tar.gz
cartcollect-aaeea0801f05cf199f27a5f6db25576d80cb403e.tar.bz2
cartcollect-aaeea0801f05cf199f27a5f6db25576d80cb403e.zip
Jump: Allowed cart to be pushed off side of screen when below ledges v0.4.6
Closes #227
Diffstat (limited to 'Classes/Cart.m')
-rw-r--r--Classes/Cart.m11
1 files changed, 9 insertions, 2 deletions
diff --git a/Classes/Cart.m b/Classes/Cart.m index cfe7ee7..0344bdf 100644 --- a/Classes/Cart.m +++ b/Classes/Cart.m
@@ -10,7 +10,7 @@
10 10
11@implementation Cart 11@implementation Cart
12 12
13@synthesize sprite, immobile, delegate, falling; 13@synthesize sprite, immobile, delegate, falling, boundedByScreen;
14 14
15- (id)initWithSprite:(CCSprite*)m_sprite 15- (id)initWithSprite:(CCSprite*)m_sprite
16{ 16{
@@ -21,6 +21,7 @@
21 sprite = m_sprite; 21 sprite = m_sprite;
22 immobile = NO; 22 immobile = NO;
23 falling = NO; 23 falling = NO;
24 boundedByScreen = YES;
24 } 25 }
25 26
26 return self; 27 return self;
@@ -32,7 +33,13 @@
32 { 33 {
33 // Move the cart based on acceleration gathered from accelerometer 34 // Move the cart based on acceleration gathered from accelerometer
34 CGPoint prevLoc = sprite.position; 35 CGPoint prevLoc = sprite.position;
35 sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); 36
37 if (boundedByScreen)
38 {
39 sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y);
40 } else {
41 sprite.position = ccp(sprite.position.x+accelX, sprite.position.y);
42 }
36 43
37 if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)])) 44 if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)]))
38 { 45 {