0

Is there any way to change the animation/physics speed of physicsbody?

I want the update method to be called 60 times a second still, I just want everything on the screen to move slowly, but still have the same property values (ie a velocity (10, 10) would still do the same thing it would just be in slow motion..)

Is there any way to induce this or is there a built in function?

One thing I can think of is dividing every movement property value by two and making gravity half what it is, but I don't think you can set the gravity and I'm not sure that would work anyway physics-wise...

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Max Hudson
  • 9,961
  • 14
  • 57
  • 107

1 Answers1

2

In order to slow down the physics simulation by a factor of two, use:

myScene.physicsWorld.speed = 0.5;
godel9
  • 7,340
  • 1
  • 33
  • 53
  • This works if you also change the world's gravity. Changing the speed doesn't affect the rate of gravity which is what I wanted to do additionaly – Max Hudson Nov 08 '13 at 20:16
  • @maxhud On my system, the code I provided (i.e. setting the `speed` property of the entire `SKPhysicsWorld` object to 0.5) does also decrease gravity by a factor of two, without having to update the `gravity` property as well. Are you seeing something different? – godel9 Nov 08 '13 at 20:20
  • I think gravity might have to be decreased by a factor of 4 because it is an exponential function. Everything appeared really "heavy" after I changed the speed property. Try it yourself. It doesn't just slow down the whole thing. It makes it disproportionate – Max Hudson Nov 08 '13 at 21:13
  • Nope definitely not the case. I can upload two versions and show you if you really don't believe me and think it's important – Max Hudson Nov 08 '13 at 21:44
  • 1
    @maxhud I've run into so many problems with Sprite Kit over the past few hours alone that I'm not surprised that you're having issues. – godel9 Nov 09 '13 at 18:47