Error for SKScene alloc

203 views Asked by At

In the SKScene gamescene I alloc the scene but it has an error message with No visible @interface with 'SKScene' declares the selector alloc.

I have think this means im not declaring it in my interface?? Corrections plz.

     -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];

// if play button touched, start transition to next scene
if ([node.name isEqualToString:@"play"]) {
    NSLog(@"play pressed");
    SKScene *GameScene = [[GameScene alloc] initWithSize:self.size];
    SKTransition *flip = [SKTransition flipVerticalWithDuration:1.0];
    [self.view presentScene:GameScene transition:flip];
   }
}
1

There are 1 answers

0
PCoder123 On BEST ANSWER

It looks like you are trying to create a variable that is the same name as the class!

SKScene *GameScene = [[GameScene alloc] initWithSize:self.size];

This is probably confusing the compiler. Change the variable name of *GameScene to something else and see if that works.