summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-11 19:55:27 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-11 19:55:27 -0400
commitf3ea6312f1e0d6a0069c41f71f6f40fdfbd8030a (patch)
tree7ff4875e8a4cc169bdd248ba5baf426a0d2f533a
parent4f226a9705d4410fe11d90a89b6cb3b06c8eadc3 (diff)
downloadcartcollect-f3ea6312f1e0d6a0069c41f71f6f40fdfbd8030a.tar.gz
cartcollect-f3ea6312f1e0d6a0069c41f71f6f40fdfbd8030a.tar.bz2
cartcollect-f3ea6312f1e0d6a0069c41f71f6f40fdfbd8030a.zip
Made falling objects on the wave destroy at the ledges v0.4.7
Previously, falling objects on the wave floated through the ledges--now they destroy when they touch the ledges just like objects not on the wave. Falling objects also now only fall straight downward if they were dropped while the wave was active.

Closes #221
-rwxr-xr-xClasses/FallingObject.h2
-rwxr-xr-xClasses/FallingObject.m10
-rw-r--r--Classes/JumpGameMode.m29
3 files changed, 20 insertions, 21 deletions
diff --git a/Classes/FallingObject.h b/Classes/FallingObject.h index d3ac638..6cb0c14 100755 --- a/Classes/FallingObject.h +++ b/Classes/FallingObject.h
@@ -24,7 +24,5 @@
24- (BOOL)tick; 24- (BOOL)tick;
25- (void)collideWithCart; 25- (void)collideWithCart;
26- (void)collideWithFloor; 26- (void)collideWithFloor;
27- (BOOL)flag:(int)flag;
28- (void)setFlag:(int)flag withValue:(BOOL)value;
29 27
30@end 28@end
diff --git a/Classes/FallingObject.m b/Classes/FallingObject.m index 86edd15..85ea902 100755 --- a/Classes/FallingObject.m +++ b/Classes/FallingObject.m
@@ -93,16 +93,6 @@
93 93
94} 94}
95 95
96- (BOOL)flag:(int)flag
97{
98 return flags[flag];
99}
100
101- (void)setFlag:(int)flag withValue:(BOOL)value
102{
103 flags[flag] = value;
104}
105
106- (void)dealloc 96- (void)dealloc
107{ 97{
108 [sprite.parent removeChild:sprite cleanup:YES]; 98 [sprite.parent removeChild:sprite cleanup:YES];
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 1e55b48..b192058 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -30,7 +30,19 @@
30 30
31@end 31@end
32 32
33// FallingObject flag 0 is whether the object is floating in water 33@implementation FallingObject (Flags)
34
35- (BOOL)fellDuringWave
36{
37 return flags[0];
38}
39
40- (void)setFellDuringWave:(BOOL)value
41{
42 flags[0] = value;
43}
44
45@end
34 46
35@implementation JumpGameMode 47@implementation JumpGameMode
36 48
@@ -118,10 +130,12 @@
118 } 130 }
119 } 131 }
120 132
133 [ledges minusSet:discardedSet];
134
121 NSMutableSet* discardedObjects = [NSMutableSet set]; 135 NSMutableSet* discardedObjects = [NSMutableSet set];
122 for (FallingObject* object in objects) 136 for (FallingObject* object in objects)
123 { 137 {
124 if ((object.sprite.position.y < 86) && (![object flag:0])) 138 if (object.sprite.position.y < (64+object.sprite.boundingBox.size.height/2))
125 { 139 {
126 for (CCSprite* ledge in ledges) 140 for (CCSprite* ledge in ledges)
127 { 141 {
@@ -144,20 +158,14 @@
144 } 158 }
145 } 159 }
146 160
147 if ((waterTick >= 180) || ((waterTick > 0) && ([object flag:0]))) 161 if (object.fellDuringWave)
148 { 162 {
149 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); 163 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11));
150 } else { 164 } else {
151 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); 165 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y);
152 } 166 }
153
154 if ((waterTick > 0) && (object.sprite.position.y <= (water.position.y+80+11)))
155 {
156 [object setFlag:0 withValue:YES];
157 }
158 } 167 }
159 168
160 [ledges minusSet:discardedSet];
161 [objects minusSet:discardedObjects]; 169 [objects minusSet:discardedObjects];
162 170
163 if (rightmost <= 480) 171 if (rightmost <= 480)
@@ -396,6 +404,7 @@
396 404
397 object.sprite.position = ccp(objectX, 360); 405 object.sprite.position = ccp(objectX, 360);
398 object.sprite.scale = 1; 406 object.sprite.scale = 1;
407 object.fellDuringWave = waterTick > 0;
399 [self addChild:object.sprite]; 408 [self addChild:object.sprite];
400 409
401 [objects addObject:object]; 410 [objects addObject:object];
@@ -429,6 +438,7 @@
429 438
430 object.sprite.position = ccp(objectX, 360); 439 object.sprite.position = ccp(objectX, 360);
431 object.sprite.scale = 1; 440 object.sprite.scale = 1;
441 object.fellDuringWave = waterTick > 0;
432 [self addChild:object.sprite]; 442 [self addChild:object.sprite];
433 443
434 [objects addObject:object]; 444 [objects addObject:object];
@@ -464,6 +474,7 @@
464 474
465 object.sprite.position = ccp(objectX, 360); 475 object.sprite.position = ccp(objectX, 360);
466 object.sprite.scale = 1; 476 object.sprite.scale = 1;
477 object.fellDuringWave = waterTick > 0;
467 [self addChild:object.sprite]; 478 [self addChild:object.sprite];
468 479
469 [objects addObject:object]; 480 [objects addObject:object];