SKLightNode not working on real device [iPhone 5]

旧街凉风 提交于 2019-12-24 05:37:38

问题


I've set up a minimalistic project here which simply adds a red square and - after tapping the screen - a light source lighting it. On simulator it runs fine, but on my iPhone 5 the square just becomes invisible as soon as the light source gets added to the node tree.

Can anyone test this on other, real devices and give feedback? Any solutions? It's driving me crazy.

Here's the scene's code:

SKLightNode* lightNode;

@implementation GameScene

-(void)didMoveToView:(SKView *)view {
    //Add some node to be lit
    SKSpriteNode* node = [SKSpriteNode spriteNodeWithColor:[UIColor redColor] size:CGSizeMake(100, 100)];
    node.position = CGPointMake(self.size.width/2.0, self.size.height/2.0);
    node.lightingBitMask = 1;
    [self addChild:node];
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    //Add a light node to light the object
    if (!lightNode) {
        lightNode = [SKLightNode node];
        lightNode.categoryBitMask = 1;
        [self addChild:lightNode];
    }
    lightNode.position = [((UITouch*)[touches anyObject]) locationInNode:self];
}

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    lightNode.position = [((UITouch*)[touches anyObject]) locationInNode:self];
}

@end

回答1:


There seems to be a bug in iOS8. I've experienced the same problem and sent a bugreport to Apple. SKLightNode does not seems to work well on an iPhone5. I've tried on iPhone6 (ok), iPhone5s (ok), iPhone5 (not working - black screen), iPod5 (ok), iPad Mini Retina (ok), ipad2 (ok).



来源:https://stackoverflow.com/questions/25912880/sklightnode-not-working-on-real-device-iphone-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!