Visually distort your game, making everything shake back and forth

Article by Richard Davey. Posted on 15th Apr 2015.   @phaser_


"Today I’ll share a little snippet in order to simulate a short earthquake or visual recoil (from an explosion, maybe?).

[Almost] Everything moves back and forth rapidly for a short period of time. Solution

The first thing that would come to mind is to move all objects back and forth, because in the end we probably have access to every single object in the game. However, it is a complex process that means recomputing collisions and game rules, to say the least.

We are interested in distorting the game visually, not logically, so the notion of camera comes in handy. We just need to move the camera back and forth and the rendering engine does the rest of the work for us. The interpolation using animation, tween or a custom-coded routine; just remember to take the current camera position as a parameter."

Read the full tutorial