diff options
Diffstat (limited to 'Classes/FallingObject.m')
-rwxr-xr-x | Classes/FallingObject.m | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/Classes/FallingObject.m b/Classes/FallingObject.m index 297b426..515948e 100755 --- a/Classes/FallingObject.m +++ b/Classes/FallingObject.m | |||
@@ -7,7 +7,7 @@ | |||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "FallingObject.h" | 9 | #import "FallingObject.h" |
10 | 10 | #import "GameMode.h" | |
11 | 11 | ||
12 | @implementation FallingObject | 12 | @implementation FallingObject |
13 | 13 | ||
@@ -25,6 +25,54 @@ | |||
25 | return self; | 25 | return self; |
26 | } | 26 | } |
27 | 27 | ||
28 | - (BOOL)tick | ||
29 | { | ||
30 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
31 | |||
32 | // Move objects down | ||
33 | sprite.position = ccp(sprite.position.x, sprite.position.y-weight); | ||
34 | |||
35 | // Cart collision detection | ||
36 | CGSize first = [gameLayer.cart.sprite boundingBox].size; | ||
37 | CGSize second = [sprite boundingBox].size; | ||
38 | |||
39 | if (gameLayer.cart.sprite.position.x > (sprite.position.x - second.width/2 - first.width/2)) | ||
40 | { | ||
41 | if (gameLayer.cart.sprite.position.x < (sprite.position.x + second.width/2 + first.width/2)) | ||
42 | { | ||
43 | if (gameLayer.cart.sprite.position.y > (sprite.position.y - second.height/2 - first.height/2)) | ||
44 | { | ||
45 | if (gameLayer.cart.sprite.position.y < (sprite.position.y + second.height/2 + first.height/2)) | ||
46 | { | ||
47 | [self collideWithCart]; | ||
48 | |||
49 | return YES; | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | // Collision detection with floor | ||
56 | if (sprite.position.y - (sprite.contentSize.height/2) < 0) | ||
57 | { | ||
58 | [self collideWithFloor]; | ||
59 | |||
60 | return YES; | ||
61 | } | ||
62 | |||
63 | return NO; | ||
64 | } | ||
65 | |||
66 | - (void)collideWithCart | ||
67 | { | ||
68 | |||
69 | } | ||
70 | |||
71 | - (void)collideWithFloor | ||
72 | { | ||
73 | |||
74 | } | ||
75 | |||
28 | - (void)dealloc | 76 | - (void)dealloc |
29 | { | 77 | { |
30 | [sprite release]; | 78 | [sprite release]; |