I have an issue where I have a game over/stop function:
Hero.m
+(id)hero//The hero
{
JBHero *_hero = [JBHero spriteNodeWithTexture:heroTexture1];
_hero.name = @"hero";
return _hero;
}
- (void)stop
{
self.physicsBody.contactTestBitMask = button2Category;
/*Setting contact to the only node I want contact with when gameover is called*/
self.physicsBody.allowsRotation = YES;
[self removeAllActions];
NSLog(@"STOP");
}
GameScene.m
-(void)gameOver
{
self.isGameOver = YES;
[hero stop];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins */
if (! self.isStarted){
[self start];//Start method
self->hero.physicsBody.dynamic = YES;
}
else if (self.isGameOver){
[self clear];//Reset scene
}
else [hero jump];
}
that calls the stop function on every single collision the hero has with the obstacles. I only want it to call the stop function on the very first contact the hero has with the obstacles and ignore the following contacts. Any help would be great.