1
\$\begingroup\$

I have two physics bodies attached to two separate sprite nodes using Sprit Kit. One is a vertical line and one is a horizontal line:

//sprite with horizontal physics body
spriteMatrix[i][j].physicsBody = SKPhysicsBody(edgeFromPoint: CGPointMake(0, tileSegmentHeight), toPoint: CGPointMake(tileSegmentWidth, tileSegmentHeight))
spriteMatrix[i][j].physicsBody!.categoryBitMask = self.surfaceCatagory
spriteMatrix[i][j].physicsBody!.contactTestBitMask = heroCatagory

//sprite with vertical physics body
self.hero.physicsBody = SKPhysicsBody(edgeFromPoint: CGPointMake(self.hero.frame.width / 2, self.hero.frame.height / 2), toPoint: CGPointMake(self.hero.frame.width / 2, -20))
self.hero.physicsBody!.categoryBitMask = heroCatagory
self.hero.physicsBody!.contactTestBitMask = surfaceCatagory

What I'm want to do is test if they are intersecting on every frame, and if they are, return the x and y position of where they are intersecting. Is this even possible?

\$\endgroup\$
1
  • \$\begingroup\$ I'd like to add that I plan to implement sloped physics bodies later so being that I we know the x an y positions already isn't going to cut it. \$\endgroup\$ – tedesignz Apr 28 '15 at 5:30
1
\$\begingroup\$

You are not using collisionBitMask The class reference can be found Here

A example of code is Here which also explains very well how collisionBitMask works

\$\endgroup\$
0
\$\begingroup\$

This is not possible. Apparently, only a dynamic volume physics body can make contact with an edge body. I do not like this about Sprite Kit.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.