Pause SpriteKit physics game SKSpriteNode child

I have an SKSpriteNode with a dynamic physical body on SKNode *_fgLayer .

Now, when I pause or pause the game, I want SKSpriteNode to stay in place and not spin or fall. If I just use _fgLayer.paused = YES; , SKSpriteNode does not remain in place, but rotates and falls. If I set physicsBody.dynamic = NO; when paused and physicsBody.dynamic = YES; When it has been suspended, it will work.

However, after several attempts, I always get the following failure:

"Assertion failed: (typeA == b2_dynamicBody || typeB == b2_dynamicBody), function SolveTOI, file /SourceCache/PhysicsKit/PhysicsKit-4.6/PhysicsKit/Box2D/Dynamics/b2World.cpp, line 670."

So, I suppose setting physicsBody.dynamic = NO; and back does not work.

Does anyone have an idea how to pause dynamic physical bodies in order to stay in place when the game is paused?

+6
source share
2 answers

Try setting your World.speed physics to 0.0:

 scene.physicsWorld.speed = 0.0 

Apple SKPhysicsWorld Ref .

+19
source

Setting scene.view.paused = YES works for me - especially when there are node actions on the child server.

self.scene.view setPaused:YES

+3
source

All Articles