Domanda

I'm getting the warning with the following code

SKSpriteNode *spaceship = [SKAction sequence: @[
                          [SKAction performSelector:@selector(newSpaceship) onTarget:self],
                          [SKAction waitForDuration:0.10 withRange:0.15]]];
[self runAction: spaceship];

The warning reads Incompatible pointer types initializing 'SKSpriteNode *' with an expression of type 'SKAction *'.

I'm a newbie to Objective C and Xcode, so I can't quite figure out the problem going on here. Thanks for the help =).

È stato utile?

Soluzione

The code on the right hand side of the equals sign returns a pointer to an SKAction object, but the type of object pointer on the left side is SKSpriteNode. Just change that type to SKAction, you may also want to change the variable name to better reflect what it is.

SKAction *spaceshipAction = [SKAction ...

Altri suggerimenti

The error tells you what you're doing:

Creating an instance of SKAction. Setting it to a pointer to an instance of SKSpriteNode.

The correct code (from a compilation point of view) would be:

SKAction *spaceship = [SKAction sequence: @[...

But you haven't said what you're trying to do so I have no idea if it's logically correct. It does kind of look correct based on your usage of runAction:, assuming self is an SKNode instance.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top