Your problem is scaleXTo:-1.0
. I used the exact same command to mirror one of my sprites and as soon as I did, the little guy stopped responding to ALL contacts. Remove it and all be well again.
Objects in SpriteKit Game Stopped Colliding after iOS 7.1 update
-
28-06-2023 - |
Question
Objects in my spriteKit game stopped colliding after the iOS 7.1 update. This includes the bounds of the screen so the character just runs off screen. I'm using a bit mask to detect collisions and handling the collisions in the didBeginContact delegate method. I'll add the code for how I'm adding my SKNodes. Thanks in advance.
//main character
self.girl = [SKSpriteNode spriteNodeWithImageNamed:@"pixelgirl"];
self.girl.position = CGPointMake(self.size.width / 2, self.size.height * 0.2);
[self addChild:self.girl];
self.girl.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:self.girl.size.height / 4];
self.girl.physicsBody.dynamic = YES;
self.girl.physicsBody.affectedByGravity = NO;
self.girl.physicsBody.mass = 0.02;
self.girl.physicsBody.allowsRotation = NO;
self.girl.physicsBody.categoryBitMask = girlCategory;
self.girl.physicsBody.contactTestBitMask = tallTreeCategory | uglyTreeCategory | shortTreeCategory;
//contact object
SKSpriteNode *pixelShort = [SKSpriteNode spriteNodeWithImageNamed:@"pixelshort"];
pixelShort.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:pixelShort.size.width / 2]; //2
pixelShort.physicsBody.dynamic = NO;
pixelShort.physicsBody.categoryBitMask = uglyTreeCategory;
- (void)didBeginContact:(SKPhysicsContact *)contact
{
__block BOOL isRotating;
[self performSelector:@selector(moveDog) withObject:Nil afterDelay:.3];
isRotating = NO;
if (!isRotating) {
SKAction* action0 = [SKAction scaleXTo:1.0 duration:0.05];
SKAction* action1 = [SKAction scaleXTo:0.1 duration:0.05];
SKAction* action2 = [SKAction scaleXTo:-0.1 duration:0.05];
SKAction* action3 = [SKAction scaleXTo:-1.0 duration:0.05];
SKAction* action = [SKAction sequence:@[action0,action1,action2, action3]];
[self.girl runAction:action completion:^{
isRotating = YES;
}];
}
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow