I'm working a on retro arcade game in Sprite Kit. I'm new to this framework so I discover new things every minute but having a hard time to solve this issue i've tried to solve for the past hours.
First a screendump of the game and the physics bodies outlined by red.
http://i.imgur.com/KcbMVn4.png?1
When you hit the boxing glove button the big guy performs a punch by this method
-(void)performPunch {
SKTexture *punch1 = [SKTexture textureWithImageNamed:@"punch1"];
SKTexture *punch2 = [SKTexture textureWithImageNamed:@"punch2"];
SKTexture *punch3 = [SKTexture textureWithImageNamed:@"punch3"];
SKTexture *punch4 = [SKTexture textureWithImageNamed:@"punch4"];
SKTexture *punch5 = [SKTexture textureWithImageNamed:@"punch5"];
NSArray *animationObjects = [NSArray arrayWithObjects:punch1, punch2, punch3, punch4, punch5, nil];
SKAction *punch = [SKAction animateWithTextures:animationObjects timePerFrame:0.1];
[_tusk runAction:punch withKey:@"punch"];
}
My collision delegate looks like this
- (void)didBeginContact:(SKPhysicsContact *)contact
{
if([_tusk actionForKey:@"punch"]) {
NSLog(@"DAT HIT");
}
}
My issue here is the only way to make didBeginContact to log the hit is when the punch is being made upon the first contact with the other units. I know it's pretty easy to understand as the method name says "didBeginContact" but I need something between this and the other "didEndContact" as I want to be able to punch the guys when I stand next to them :)