user3438668
user3438668

Reputation:

SpriteKit: childNodeWithName – Warning incompatible pointer types

when I try to use:

SKSpriteNode *player = [self childNodeWithName:@"player"];

"Incompatible pointer types initializing 'SKSpriteNode *' with an expression of type 'SKNode *'"

How do I fix that?? Thanks!

Upvotes: 1

Views: 628

Answers (1)

user867635
user867635

Reputation:

You fix it by converting your variable from SKNode to SKSpriteNode. It's called Type Casting.

SKSpriteNode *player = (SKSpriteNode *)[self childNodeWithName:@"player"];

Upvotes: 4

Related Questions