Cocos2d - CCLabelTTF在更新时覆盖新值

时间:2014-05-06 02:06:57

标签: ios cocos2d-iphone

我有一个CCLabelTTF变量定义如下

@implementation LevelScene
{
    CCLabelTTF *_collectedLabel;

    int collectedStars1;
    int collectedStars2;
    int collectedStars3;
}

我还有一个CCScrollView,我会听scrollViewDidScroll

- (void)setPageIndicatorTo:(NSInteger)page
{
    if (page == 0) {
        _collectedLabel.string = [NSString stringWithFormat:@"%d/75", collectedStars1];
    } else if (page == 1) {
        _collectedLabel.string = [NSString stringWithFormat:@"%d/75", collectedStars2];
    } else if (page == 2) {
        _collectedLabel.string = [NSString stringWithFormat:@"%d/75", collectedStars3];
    }
}

- (void)scrollViewDidScroll:(CCScrollView *)scrollView
{
    [self setPageIndicatorTo:_scrollView.horizontalPage];
}

didLoadFromCCB中,我将_collectedLabel.string设置为某个值。它给了我以下内容:

enter image description here

当视图滚动时,它会调用- (void)setPageIndicatorTo:(NSInteger)page,从而更新字符串。然后我得到

enter image description here

它应该是0/75。新标签覆盖了前一个标签......如何强制更新字符串?


我尝试将字符串设置为""在将其设置为另一个值之前,它给出了相同的结果..

0 个答案:

没有答案
相关问题