2

I have the debugging fields enabled in my scene, such as:

skView.showsFPS = YES;
skView.showsNodeCount  YES;

Unfortunately, the position, size and text color does not work well with my scene, and the debugging text is very hard to read. I would like to move them out of the lower right corner and, ideally, make them bigger. I thought maybe they were child nodes or subviews, so I tried the following, but both checks came up empty.

-(void)didMoveToView:(SKView *)view
{
    NSArray *subViews = [view subviews];
    for (UIView *subView in subViews)
    {
        NSLog(@"Node at %.0f,%.0f", subView.frame.origin.x, subView.frame.origin.y);
    }

    [self enumerateChildNodesWithName:@"*" usingBlock:^(SKNode * _Nonnull node, BOOL * _Nonnull stop)
    {
        NSLog(@"Node at %.0f,%.0f", node.position.x, node.position.y);
    }];

}

Is there any way to access the scene's debugging text in order to move or resize them? Using private APIs would be fine, as this is only applicable during pre-release testing and will be removed before shipping.

Thunk
  • 4,099
  • 7
  • 28
  • 47

1 Answers1

0

There are no public properties which allow styling or centering of these labels. But it's not a big deal...Those labels shows just draws, nodes and quad count. And that's it. Also, the debug area takes about 15 points in height. I would say that is not really much if you need debugging info enabled.

Also it is placed at the bottom of the screen...So, something like this can be useful:

import SpriteKit

class GameScene: SKScene {

    override func didMoveToView(view: SKView) {

        backgroundColor = .whiteColor()

        let debugAreaBackground = SKSpriteNode(color: .blackColor(), size: CGSize(width: frame.size.width, height: 15))

        debugAreaBackground.position = CGPoint(x: frame.midX, y: debugAreaBackground.size.height/2.0)
        debugAreaBackground.alpha = 0.5
        addChild(debugAreaBackground)

    }
}

We have a white background here, so debug info will be "invisible" due to fact that used font for debug labels is white. So adding a black background node with height of just 15 points will solve the problem. Making that node transparent allows you to see the scene content behind this background node.

Also, you can get nodes count programatically and you can disable that info and place your own label somewhere else. To get nodes count you can count children array. To get all of the nodes in the tree (visible and offscreen) you can use enumerateChildNodesWithName method and pass something like this as search string :

//*

Read more here.

Community
  • 1
  • 1
Whirlwind
  • 14,286
  • 11
  • 68
  • 157
  • Thanks, but the conflict isn't with scene contents behind the debug text, its with non-scene elements presented in front of the scene that need a fixed position. And, we're chasing a frame-rate / node-count kind of bug, so that's exactly the info I need need. :/ I guess I'll have to just display it myself. – Thunk Mar 26 '16 at 22:53
  • @Thunk Ah okay. Well, some compensation has to be made at the moment of speaking. Or who knows, maybe somebody will came up with a solution eventually. – Whirlwind Mar 26 '16 at 22:57