Domanda

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!

È stato utile?

Soluzione

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

Altri suggerimenti

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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top