summary refs log tree commit diff stats
path: root/Classes/Cart.m
diff options
context:
space:
mode:
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 {