为什么我的模拟器仍显示节点数和FPS? [SpriteKit]

时间:2014-07-27 21:36:01

标签: ios objective-c sprite-kit

我准备将我的游戏发布到应用程序商店。在我这样做之前,我想关闭节点数和FPS,并且不希望显示这两件事。我有一个GameScene.m和一个TitleScene.m。我在 GameScene.m 中尝试了view.showsFPS = NO;view.showsNodeCount = NO;,它运行正常。在我的 TitleScene.m 中,我尝试了self.view.showsNodeCount = NO;self.view.showsFPS = NO;,但它仍然显示了NodeCount和FPS。这是我的TitleScene.m代码:

#import "TitleScene.h"
#import "GameScene.h"

@implementation TitleScene

-(id)initWithSize:(CGSize)size {
    if (self = [super initWithSize:size]) {
        /* Setup your scene here */

        self.view.showsNodeCount = NO;
        self.view.showsFPS = NO;

        SKTexture *YellowLabelTexture = [SKTexture textureWithImageNamed:@"YellowLabel.png"];
        SKTexture *BlueLabelTexture = [SKTexture textureWithImageNamed:@"BlueLabel.png"];
        SKTexture *GreenLabelTexture = [SKTexture textureWithImageNamed:@"GreenLabel.png"];
        SKTexture *RedLabelTexture = [SKTexture textureWithImageNamed:@"RedLabel.png"];
        SKTexture *WhiteLabelTexture = [SKTexture textureWithImageNamed:@"WhiteLabel.png"];

        SKSpriteNode *background = [SKSpriteNode spriteNodeWithImageNamed:@"awsome.png"];
        background.size = CGSizeMake(640, 1136);
        background.position = CGPointMake(0,0);

        NSArray *anim = [NSArray arrayWithObjects:YellowLabelTexture, BlueLabelTexture, GreenLabelTexture, RedLabelTexture, WhiteLabelTexture, nil];

        SKSpriteNode *labelNode = [SKSpriteNode spriteNodeWithImageNamed:@"WhiteLabel.png"];
        labelNode.position = CGPointMake(self.size.width / 2, self.size.height / 2 * 1.5);

        SKSpriteNode *startButtonNode = [SKSpriteNode spriteNodeWithImageNamed:@"playButton.png"];
        startButtonNode.position = CGPointMake(self.size.width / 2, self.size.height / 3);

        SKAction *actionAnimate = [SKAction animateWithTextures:anim timePerFrame:.3 resize:YES restore:NO];
        SKAction *actionRepeat = [SKAction repeatActionForever:actionAnimate];
        [labelNode runAction:actionRepeat];

        [self addChild:background];
        [self addChild:labelNode];
        [self addChild:startButtonNode];

    }
    return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    GameScene* gameScene = [[GameScene alloc] initWithSize:self.size];
    gameScene.scaleMode = SKSceneScaleModeAspectFill;
    [self.view presentScene:gameScene transition:[SKTransition doorsOpenHorizontalWithDuration:1.5]];
}

我做错了吗?谢谢!

2 个答案:

答案 0 :(得分:6)

默认的SpriteKit模板在ViewController.m中初始化场景后设置节点数和fps,您必须删除这些行。

答案 1 :(得分:1)

注释显示ViewController.m文件中的FPS和ShowsNodeCount;

//skView.showsFPS = YES;
//skView.showsNodeCount = YES;