SpriteKit textureFromNode返回黑色图像

时间:2014-01-24 12:58:10

标签: sprite-kit

以下是示例代码:

    SKNode* node = [SKNode node];
    node.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
    [self addChild: node];

    SKSpriteNode *sprite1 = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
    sprite1.position = CGPointMake(-900.0, -900.0);
    [node addChild: sprite1];

    SKSpriteNode *sprite2 = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
    sprite2.position = CGPointMake(900.0, 900.0);
    [node addChild: sprite2];        

    [self runAction: [SKAction sequence: @[[SKAction waitForDuration: 3.0], [SKAction runBlock:^{

        SKTexture* texture = [self.view textureFromNode: node];
        SKSpriteNode* ts = [SKSpriteNode spriteNodeWithTexture: texture];
        ts.xScale = 1.0 / [UIScreen mainScreen].scale;
        ts.yScale = 1.0 / [UIScreen mainScreen].scale;
        [self addChild: ts];
    }]]]];

一旦我将两个精灵彼此远离,使容器节点的累积框架变大,我就会变黑纹理?

0 个答案:

没有答案