Cocos2d得分重置正在搞乱(长期警告)

时间:2012-07-07 14:58:43

标签: iphone ios5 xcode4 cocos2d-iphone

分数根本没有重置,我试图制作一个高分计数器,每次你通过以前的高分时它都会更新。但是,现在它正在游戏中重置。例如,如果我在比赛期间得分为2,那么只需将3分作为高分,而不是继续上升直到游戏结束。我得出结论,我需要在gameoverlayer中重置它,以便在游戏过程中不会重置。我一直试图这样做,但没有运气。

gameover .m

          CGSize winSize = [[CCDirector sharedDirector] winSize];    
_score = [[NSUserDefaults standardUserDefaults] integerForKey:@"score"];           


_oldScore = -1;
self.scoreLabel = [CCLabelTTF labelWithString:@"" dimensions:CGSizeMake(100, 50) alignment:UITextAlignmentRight fontName:@"Marker Felt" fontSize:32];
_scoreLabel.position = ccp(winSize.width - _scoreLabel.contentSize.width, _scoreLabel.contentSize.height);
_scoreLabel.color = ccc3(255,0,0);
[self addChild:_scoreLabel z:1];         








if (_score > _oldScore) {

    _oldScore = _score;

    [_scoreLabel setString:[NSString stringWithFormat:@"score%d", _score]];

    [[NSUserDefaults standardUserDefaults] setInteger:_oldScore forKey:@"score"];


    _score =0;

hello world(我的游戏)的.h文件的相同代码,除了没有_score = 0; 我希望它能重置游戏中的分数,但现在却不断上升

0 个答案:

没有答案