SpriteKit enumerateChildNodesWithName with advanced searching?

前端 未结 1 1564
野的像风
野的像风 2021-02-09 10:39

The following code doesn\'t work as expected. According to the SPRITE KIT PROGRAMMING GUIDE, pages 61 and 62 one may perform \"advanced searches\" by using regular expression l

相关标签:
1条回答
  • 2021-02-09 11:16

    I tried the following variation of your code in both the current and beta versions of Xcode on both iOS and OS-X.

        SKScene *scene = [[SKScene alloc] initWithSize:self.gameView.frame.size];
    
        for (int x = 0; x < 20; x++)
        {
            for (int y = 0; y < 20; y++)
            {
                CGPathRef myPath = CGPathCreateWithEllipseInRect(CGRectMake(0, 0, 20, 20), NULL);
                SKShapeNode *myCircle = [[SKShapeNode alloc] init];
                myCircle.path = myPath;
    #if TARGET_OS_IPHONE
                myCircle.fillColor = [UIColor redColor];
    #else
                myCircle.fillColor = [NSColor redColor];
    #endif
                myCircle.name = [NSString stringWithFormat:@"CIRCLE_%d_%d", x, y];
                myCircle.position = CGPointMake(20*x,20*y);
                [scene addChild:myCircle];
                CGPathRelease(myPath);
            }
        }
    
        [self.gameView presentScene:scene];
    

    All of your sample expressions work on the Mac in both versions of the SDK. On iOS, however, they only worked in the Developer Preview.

    0 讨论(0)
提交回复
热议问题