-3

Problem Running this error consistently.

This exact code works fine in another application so I'm doubting it's the issue.

-(void)didMoveToView:(SKView *)view {
    self.anchorPoint = CGPointMake(0.5, 0.5);
    self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];

    cards = [[NSMutableArray alloc] init];
    func *functions = [[func alloc]init];
    [functions arrayWithRangeFrom:1 to:52 id:cards];

    //Add background
    NSString *bundle = [[NSBundle mainBundle] pathForResource:@"background" ofType:@"png"];
    UIImage *image = [[UIImage alloc] initWithContentsOfFile:bundle];
    SKTexture *texture = [SKTexture textureWithImage:image];
    background = [SKSpriteNode spriteNodeWithTexture:texture];
    background.size = CGSizeMake(self.frame.size.width, self.frame.size.height);
    background.position = CGPointMake(0.5, 0.5);
    background.zPosition = 0;
    background.name = @"backgroundImage";
    [self addChild:background];
    //END Add Background
}

Returns that error.

.png file is 42kb @ 1920x1080 res.

It's in the supporting files, and is in the images directory.

I'm not sure where to go from here ?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
user2415313
  • 101
  • 1
  • 10
  • `background = [SKSpriteNode spriteNodeWithTexture:texture];` – user2415313 Feb 13 '15 at 02:18
  • @matt Under thread1 i get, Queue: com.apple.main-thread (serial) – user2415313 Feb 13 '15 at 02:18
  • So debug it! Put a breakpoint at `NSString *bundle = ` and walk through the code, looking at the variable set in each line. Is the string set? Is the image set? Is the texture set? Find out. Figure out what's crashing and why. – matt Feb 13 '15 at 02:20
  • @matt bundle = (nsstring *) nil But how? the image is imported, named correctly and in the supporting files – user2415313 Feb 13 '15 at 02:22
  • removed the reference, and added it again. And now no errors. How did I achieve such an error in the first place? – user2415313 Feb 13 '15 at 02:24

1 Answers1

0

Solution

Removed the reference of the image and re-added. Fixed the issue, unsure as to the initial reason.

user2415313
  • 101
  • 1
  • 10
  • The image was in the _project_ but you forget to make it part of the _target_. The second time, you did make it part of the target. – matt Feb 13 '15 at 03:03