I created a ball object to later show on screen when I tap it. However when I try to do that, it gives me an error. Unfortunately i can't make something out of it.
ballClass.h:
@import SpriteKit;
#import "ballClass.h"
@implementation ballClass
+ (SKSpriteNode*)ballNode {
SKSpriteNode* node = [SKSpriteNode spriteNodeWithImageNamed:@"Ball"];
return node;
}
@end
ballClass.m:
#import <Foundation/Foundation.h>
@interface ballClass : NSObject
+ (SKSpriteNode*)ballNode;
@end
My touchesBegan method in my game scene.m:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
SKSpriteNode *ball = [ballClass ballNode];
ball.position = location;
[self addChild:ball];
}
}
Any help would be greatly appreciated. Thanks in advance.