I have a player in my game, it has two states flying, falling. Each of them has an image: player_flying, player_falling correspondingly. I am also using a physical bodies to detect collision. It is completely normally functioning when I use one texture. But when I am trying to use both in different conditions using different textures, it shows me an error in the log. I am trying it like that:
if (self.player.physicsBody.velocity.dy > 30) { self.player.texture = [SKTexture textureWithImageNamed:@"player_flying"]; self.player.physicsBody = [SKPhysicsBody bodyWithTexture:self.player.texture size:self.player.size]; } else { self.player.texture = [SKTexture textureWithImageNamed:@"player_falling"]; self.player.physicsBody = [SKPhysicsBody bodyWithTexture:self.player.texture size:self.player.size]; }
the error is:
2014-08-30 12:55:47.515 kalabaska[1569:50535] PhysicsBody: Could not create physics body.