문제

I'm getting the following warning from the line

self.physicsWorld.contactDelegate = self;

Assigning to 'id' from incompatible type 'PlayLevel *__strong'

-(id)initWithSize:(CGSize)size level:(int)level{
    if (self = [super initWithSize:size]) {
        _level = level;
        self.physicsWorld.gravity = CGVectorMake(0,0);
        self.physicsWorld.contactDelegate = self;

Not at all sure what's causing it. This is what my header looks like:

#import <SpriteKit/SpriteKit.h>

@interface PlayLevel : SKScene

-(id)initWithSize:(CGSize)size level:(int)level;

@end

Any idea's what's causing it? I kind of need a contactDelegate. Thanks!

도움이 되었습니까?

해결책

You should declarer on your class interface (inside <>) that your class implement the delegate.

다른 팁

you will have to add the delegate reference in your header file. For example if we are using the UINavigationController delegates we add <UINavigationControllerDelegate> in the header file. Similary you will have to add the contact delegate

In your header where you declare that PlayLevel extends SKScene, you need to also declare that it implements the SKContactDelegate interface like so:

@interface PlayLevel : SKScene <SKPhysicsContactDelegate>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top