user4616250
user4616250

Reputation: 221

Test contact between 2 static physics bodies

My app has a set of horizonal bars (obstacles) that move up from the bottom of the screen. When they hit an invisible horizontal bar at the bottom 1/3rd of the screen, I want to spawn another set of obstacles.

I have set the spawning bar to be a gray rectangular sprite for now, just for debugging. When the obstacles move upwards, they simply pass under the spawning bar and no contact is detected. However, when I set the physicsBody.dynamic property of the spawning bar to "YES" the contact is detected. I can't use this, though, because it would push the bar offscreen.

Is there a problem with detecting contact between 2 non-dynamic bodies? How can I fix this?

Upvotes: 2

Views: 714

Answers (1)

user4616250
user4616250

Reputation: 221

Whoops, I upon further research, Sprite Kit doesn't check for contact between 2 static bodies. I had to set one of them to dynamic.

Upvotes: 1

Related Questions