summary refs log tree commit diff stats
path: root/Classes/JumpGameMode.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/JumpGameMode.m')
-rw-r--r--Classes/JumpGameMode.m54
1 files changed, 49 insertions, 5 deletions
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index f0cb469..af51a70 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -10,6 +10,7 @@
10#import "SimpleAudioEngine.h" 10#import "SimpleAudioEngine.h"
11#import "FallingObject.h" 11#import "FallingObject.h"
12#import "GameOverScene.h" 12#import "GameOverScene.h"
13#import "ScoreBarLayer.h"
13 14
14#define kMinimumGestureLength 25 15#define kMinimumGestureLength 25
15 16
@@ -41,6 +42,8 @@
41 42
42@implementation JumpGameMode 43@implementation JumpGameMode
43 44
45@synthesize score, lives, pointMultiplier;
46
44typedef enum { 47typedef enum {
45 kRockObject = 0, 48 kRockObject = 0,
46 kOneUpObject, 49 kOneUpObject,
@@ -75,6 +78,33 @@ static GameModeInfo* info;
75 backgroundImage.position = ccp(240, 160); 78 backgroundImage.position = ccp(240, 160);
76 [self addChild:backgroundImage z:-1]; 79 [self addChild:backgroundImage z:-1];
77 80
81 score = 0;
82 lives = 3;
83 pointMultiplier = 1;
84
85 ScoreBarLayer* scoreBar = [ScoreBarLayer scoreBar];
86 [self addChild:scoreBar];
87
88 scoreLabel = [CCLabelBMFont labelWithString:@"0" fntFile:@"helvetica2.fnt"];
89 scoreLabel.position = ccp(30,20);
90 [scoreBar addChild:scoreLabel];
91
92 CCSprite* livesImage = [CCSprite spriteWithFile:@"oneup.png"];
93 livesImage.position = ccp(110, 20);
94 [scoreBar addChild:livesImage];
95
96 livesLabel = [CCLabelBMFont labelWithString:@"x3" fntFile:@"helvetica2.fnt"];
97 livesLabel.position = ccp(142,20);
98 [scoreBar addChild:livesLabel];
99
100 CCSprite* pointMultiplierImage = [CCSprite spriteWithFile:@"multiplier.png"];
101 pointMultiplierImage.position = ccp(190, 20);
102 [scoreBar addChild:pointMultiplierImage];
103
104 pointMultiplierLabel = [CCLabelBMFont labelWithString:@"x1" fntFile:@"helvetica2.fnt"];
105 pointMultiplierLabel.position = ccp(222,20);
106 [scoreBar addChild:pointMultiplierLabel];
107
78 water = [CCSprite spriteWithFile:@"water.png"]; 108 water = [CCSprite spriteWithFile:@"water.png"];
79 water.position = ccp(240, -60); 109 water.position = ccp(240, -60);
80 [self addChild:water]; 110 [self addChild:water];
@@ -491,16 +521,30 @@ static GameModeInfo* info;
491 [self setScore:self.score+pointMultiplier]; 521 [self setScore:self.score+pointMultiplier];
492} 522}
493 523
494- (void)setLives:(int)m_lives 524- (void)setScore:(int)m_score
495{ 525{
496 int oldLives = lives; 526 score = m_score;
497
498 [super setLives:m_lives];
499 527
500 if (oldLives > lives) 528 [scoreLabel setString:[NSString stringWithFormat:@"%d", score]];
529}
530
531- (void)setLives:(int)m_lives
532{
533 if (m_lives < lives)
501 { 534 {
502 [self setPointMultiplier:1]; 535 [self setPointMultiplier:1];
503 } 536 }
537
538 lives = m_lives;
539
540 [livesLabel setString:[NSString stringWithFormat:@"x%d", lives]];
541}
542
543- (void)setPointMultiplier:(int)m_pointMultiplier
544{
545 pointMultiplier = m_pointMultiplier;
546
547 [pointMultiplierLabel setString:[NSString stringWithFormat:@"x%d", pointMultiplier]];
504} 548}
505 549
506- (void)didCatchItem:(FallingObject *)item 550- (void)didCatchItem:(FallingObject *)item