Nolan D.
Nolan D.

Reputation: 25

SKSpriteNode not showing up when added

I was using Objective-C and SpriteKit. I made a SKSpriteNode of a simple ball, then added it. Unfortunately, it's not showing up.

-(void)didMoveToView:(SKView *)view {
/* Setup your scene here */

// Set background color
self.backgroundColor = [SKColor whiteColor];

// Creating a new spritenode from an image
SKSpriteNode *ball = [SKSpriteNode spriteNodeWithImageNamed: @"ball"];

// Add the sprite node to the scene
[self addChild: ball];

Upvotes: 0

Views: 677

Answers (1)

WangYudong
WangYudong

Reputation: 4423

Did you forget to set the sprite's position?

ball.position = CGPointMake(CGRectGetMidX(self.scene.frame), CGRectGetMidY(self.scene.frame));

Upvotes: 1

Related Questions