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!
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
Shaun Kelly5,648 Points
Why cant i use CAKeyFrameAnimation with SpriteKit ?
I cannot add the animation to the node because it should be [node addAnimation:animation forKey:nil]; instead but there is an error that says "NO visible @interface for 'SKSpriteNode' declares the selector 'addAnimation:forkey'". ?
SKSpriteNode *node = [SKSpriteNode spriteNodeWithColor:[SKColor redColor] size:CGSizeMake(40, 40)]; node.name = @"node"; node.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)); [self addChild:node]; CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.x"]; animation.values = @[@0, @20, @-20, @0]; animation.keyTimes = @[@0, @0.25, @0.50, @0.75, @1.0]; animation.duration = 2.0; animation.repeatCount = 1.0; [node animationDidStart:animation];