0
\$\begingroup\$

Is there a way to modify the rate that physics is applied, either globally or on a per-sprite basis in Phaser? That is, how can I slow down or speed up the rate at which sprites move around, or fall due to gravity? One use case would be for the "bullet time" effect - by slowing down the physics rate for everything else apart from the player character.

I understand that the way physics works is that deltas are applied to sprite bodies every frame, based on the game.time.elapsed value. One method would be to set a custom multiplier on this elapsed value so movements happen slower or faster, but is this possible?

Alternately, I could apply all the physics effects myself, but can I do this without losing compatibility with the rest of the physics system?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Slowing down time globally is possible, via the game.time.slowMotion variable. It defaults to 1.0, setting it to 2.0 makes things half speed for example.

There's a demo on the Phaser examples page under Time > Slow Down Time. It appears that when slowed down, the number of updates slows down (i.e. movement becomes less frequent and jerky) as opposed to things moving as frequently but in smaller increments, which may or may not be what you want. The example doesn't show what happens when setting this number < 1.0.

From what I can find in the docs, there's no way to set this on a per-sprite basis.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .