【问题标题】:sprite kit contact delegate精灵套件联系代表
【发布时间】:2014-02-16 04:15:18
【问题描述】:

当我尝试添加时:

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];
}

【问题讨论】:

    标签: sprite-kit


    【解决方案1】:

    刚刚找到解决办法,需要把.h文件改成,符合协议,像这样:

    @interface MGLCreateMainGameScene : SKScene <SKPhysicsContactDelegate>
    

    需要添加&lt;SKPhysicsContactDelegate&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多