Search code examples
sprite-kitskphysicscontact

SPriteKit Handling collision behaviour from different Angles


I am working on game, in which i need different collision behaviours from different side,

Suppose there is a character when it collide to any other obstacle from down side, it will behave
differently.

when it collide to any other obstacle or object while it is at top and the obstacle or object is below it, then i need different behavior,

what is the best way to acheive it.-(void)didBeginContact:(SKPhysicsContact*)contact how it be
helpfull in my scenario

Thanks


Solution

  • LearnCocos2D guided me in Right direction

    skphysicscontact gives you the contact point developer.apple.com/library/ios/documentation/SpriteKit/… Check where contact point is in relation to nodeA and nodeB position. Ie if posA.x < contactpoint.x and posB.x > contactpoint.x the contact was to the right of nodeA.