当我尝试添加:
self.physicsWorld.contactDelegate = self;
到我的主场景的代码我得到以下错误:
'从不兼容的类型'MGLCreateMainGameScene * const_strong'
分配给'id'我该如何解决这个问题?这就是我所拥有的:
-(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];
}
答案 0 :(得分:3)
刚刚找到修复程序,需要将.h文件更改为符合协议,如下所示:
@interface MGLCreateMainGameScene : SKScene <SKPhysicsContactDelegate>
需要添加<SKPhysicsContactDelegate>