0
votes

When i try to add:

self.physicsWorld.contactDelegate = self;

to the code of my main scene i get the following error:

'Assigning to 'id' from incompatible type 'MGLCreateMainGameScene *const_strong'

How can i fix this? This is what i have:

-(void)createMainGameScene
{
    self.currentBackground = [MGLBackground generateNewBackground];
    self.scaleMode = SKSceneScaleModeAspectFit;
    self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
    self.physicsWorld.gravity = CGVectorMake(0.0, -3.0);
    self.physicsWorld.contactDelegate = self;
    [self addChild:self.currentBackground];
}
1

1 Answers

3
votes

Just found the fix, needed to change the .h file to, conform to the protocol, like this:

@interface MGLCreateMainGameScene : SKScene <SKPhysicsContactDelegate>

Needed to add the <SKPhysicsContactDelegate>