iphone - 使用 cocos2d 在 iPhone 上显示游戏分数的最佳方式?

标签 iphone objective-c cocoa-touch cocos2d-iphone

我希望使用 cocos2d 在 iPhone 应用程序中持续显示游戏分数。关闭 cocos2d 显示应用程序运行的 FPS 的代码:

-(void) showFPS
{
    frames++;
    accumDt += dt;

    if ( accumDt > 0.1)  {
        frameRate = frames/accumDt;
        frames = 0;
        accumDt = 0;
    }

    NSString *str = [NSString stringWithFormat:@"%.1f",frameRate];
    [FPSLabel setString:str];
    [FPSLabel draw];
}

我可以让分数正确显示,但它会闪烁,即使应用程序以超过 60 FPS 的速度运行......有什么想法吗?

最佳答案

对于任何可能感兴趣的人,我最终使用了一个 cocos2d 标签:

scoreLabel = [Label labelWithString: [NSString stringWithFormat:@"%d", score] dimensions: CGSizeMake(180, 20) alignment: UITextAlignmentRight fontName:@"Arial" fontSize: 20];
[scoreLabel setPosition: cpv(100,100)];
[self add: scoreLabel];

希望这可以帮助其他人。

关于iphone - 使用 cocos2d 在 iPhone 上显示游戏分数的最佳方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/337732/

相关文章:

ios - 不提示用户的 UILocal 通知?

iphone - 无法加载从设备上运行的包中的 nib 引用的图像

ios - UITableView reloadData 似乎不会导致 cellForRowAtIndexPath : to be called

cocoa-touch - CMutablePointer<NSRange> 死胡同

iphone - iPhone 应用程序中网页 View 上的手势识别器

iphone - UIToolBar 高度不会改变

iphone - 界面构建器的尺寸检查器中的框架和布局有什么区别?

ios - 为什么 UIPageViewControllers 中的 ViewControllers 不能使用自动布局正确调整?

objective-c - 以编程方式选择 NSMatrix 的项目

iphone - 如果使用其他 NSMutableArray 初始化,如何更新 NSMutableArray