Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

SpriteKit greenNode won't show up on scene

I am following the SpriteKit course and my node won't show up. I got the background color to change but thats all.

'''Objective-C

self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0];


SKSpriteNode *greenNode  = [SKSpriteNode spriteNodeWithColor:[SKColor greenColor] size:CGSizeMake(100, 100)];

[self addChild:greenNode];

} '''

Now i am in Xcode 6 because I'm testing something out but my target is for iOS 7.

This still does nothing.

2 Answers

Hard to say, not enough information. You didn't provided information what class is "self"? ..how is it implemented or where? Maybe you are missing position?

As an example that works fine for me and was shown in "Build a Game with Sprite Kit" course:

+ (instancetype)groundWithSize:(CGSize)size {
    THGroundNode *ground = [self spriteNodeWithColor:[SKColor greenColor] size:size];
    ground.position = CGPointMake(size.width/2, size.height/2);
    return ground;
}

I figured it out, like i said above I am working in Xcode 6 to test some features and the code is a little different.

Lee Hardy
Lee Hardy
5,407 Points

Hi Anthony,

Can I ask how you resolved this please?

I'm in the same situation, using XCode 6 and am not seeing the green sknode appearing, however I've checked and double checked my code and its all ok

I did download the treehouse project file and that ran fine. However, when I copy the relevant code from the sample into my project, the green node doesnt appear

Thanks