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

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -