Pregunta

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!

¿Fue útil?

Solución

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

Otros consejos

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top