我有一个问题,我有游戏结束/停止功能:
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];
}
在英雄与障碍物的每次碰撞中调用停止功能。我只希望它在英雄与障碍物的第一次接触时调用停止功能并忽略以下接触。 任何帮助都会很棒。