ios - Different Collisions -
i have 2 collisions in game happen when main characters hits obstacle, game on appears , 1 touches ground , nothing happens. codes
-(void)didbegincontact:(skphysicscontact *)contact { if ([contact.bodya.node.name isequaltostring:@"ground"] || [contact.bodyb.node.name isequaltostring:@"ground"]) { [hero land]; } else { [self gameover]; }
how can add different main character/hero collision doesn't lead me game on whole different outcome (like different reaction main character)
try detecting contact other special cases:
-(void)didbegincontact:(skphysicscontact *)contact { bool iscontactwithground = ([contact.bodya.node.name isequaltostring:@"ground"] || [contact.bodyb.node.name isequaltostring:@"ground"]); bool iscontactwithhero = ([contact.bodya.node.name isequaltostring:@"hero"] || [contact.bodyb.node.name isequaltostring:@"hero"]); bool iscontactwithotherthing = ([contact.bodya.node.name isequaltostring:@"otherthing"] || [contact.bodyb.node.name isequaltostring:@"otherthing"]); if (iscontactwithhero && iscontactwithground) { [hero land]; } else if (iscontactwithhero && iscontactwithotherthing) { [self dosomethingelse]; else { [self gameover]; } }
Comments
Post a Comment