
Make Every Hit Land Harder: Phaser Camera Shake and Flash for Beginners
You’ve built a working game. Your player swings, the enemy takes damage, the health bar drops — all the logic is correct. And yet, every hit feels… limp. Like you’re punching through a pillow. The good news: you don’t need particles, plugins, or a physics overhaul to fix that. Phaser’s Camera class ships with built-in special effects, and two of them — shake() and flash() — are a quick, built-in way to make an impact feel like an impact. In this post, you’ll learn exactly how both work, what their defaults are, and how to combine them into a tiny “hit handler” you can drop into any existing project. If you’re using AI tools to help build your game, you can even paste these calls straight into a prompt and have your assistant wire them into your damage code for you.
A quick honesty note: This post is based on the official Phaser Camera docs (Phaser v4.1.0 at the time of writing). The docs page links to its matching Camera.js source for anyone who wants the implementation; this post does not rely on it. The snippets were not run hands-on by the author, so treat them as a starting point and verify behavior in your own project.
Why your hits feel weak (and what “game juice” means)
Game developers have a loose, affectionate term for the polish that makes actions feel satisfying: game juice. The idea is simple — instead of letting an action like a hit exist as pure logic, you layer small pieces of feedback on top of it. A screen shake says “that mattered.” A flash of color says “something just happened right here.” Add particles, a sound effect, or a brief animation, and suddenly the same mechanical hit feels powerful.
None of these layers change the game’s rules. A shake doesn’t deal more damage. What it changes is how the moment reads to the player. Juice is built from small, cheap effects stacked together.
The catch for beginners is that juice can sound like a big topic — particle systems, shaders, animation curves. It doesn’t have to be. In this post we’re staying entirely inside one object: your scene’s main camera. Two method calls, no dependencies, no plugins. That’s the whole toolkit.
Meet the camera’s built-in effects
In Phaser, every scene has a camera you can reach with this.cameras.main. Per the Phaser Camera docs, “A Camera also has built-in special effects including Fade, Flash and Camera Shake.” That’s what makes these two effects such a great first juice tool: they’re not something you add — they’re already there, waiting to be called.
Here are the two method signatures we’ll use:
// Camera shake
this.cameras.main.shake(duration, intensity, force, callback, context);
// Camera flash
this.cameras.main.flash(duration, red, green, blue, force, callback, context);
Every parameter is optional. If you call either method with no arguments, Phaser uses documented defaults:
| Method | Default duration | Other defaults |
|---|---|---|
shake() |
100 ms | intensity 0.05, force false |
flash() |
250 ms | color 255, 255, 255 (white) |
You can absolutely start with the defaults — they’re sensible starting points. But knowing what each parameter does means you can tune the feel later, which is where the fun begins.
Your first shake
The shake effect, in the docs’ own words, “shakes the Camera by the given intensity over the duration specified.” Note what it shakes: the camera, not your sprites, not the world. The whole view wobbles for a moment, which reads to the player as impact.
The shortest possible version uses the documented defaults — a duration of 100 ms and an intensity of 0.05:
this.cameras.main.shake();
That single line is a real, working effect. If you want to be explicit about it, this is exactly the same thing:
// Same as the defaults: 100 ms duration, 0.05 intensity
this.cameras.main.shake(100, 0.05);
Two things worth knowing:
- Duration is in milliseconds. The documented default is 100 ms — a quick, snappy wobble.
- Intensity controls how strongly the camera shakes, and per the docs it may be a number or a
Phaser.Math.Vector2. The docs don’t elaborate on what each Vector2 value controls, so treat that as an advanced option to explore later.
The shake method has been part of the API since Phaser 3.0.0, so you’ll see it in tutorials and AI-generated code across the whole modern Phaser era.
If you want to experiment with a different feel, try tuning the values — for example, a longer duration or a different intensity — and see what reads well for your game. There’s no universally “correct” value; it’s a matter of taste and playtesting your own project.
Add a flash of color
Where shake wobbles the view, flash washes it in color. The docs describe it precisely: flashing the camera works “by setting it to the given color immediately and then fading it away again quickly over the duration specified.”
The default is a 250 ms flash in white (255, 255, 255):
this.cameras.main.flash(250, 255, 255, 255);
Called with no arguments at all, this.cameras.main.flash() gives you that same default white flash. The effect is instant — the screen snaps to the color, then fades back over the duration. It’s the visual equivalent of a camera flashbulb going off.
The color channels (red, green, blue) are tunable. For example, here’s a warm orange-tinted flash — note that these values are just an example to play with, not a documented default or a recommendation:
// Example values to tune — try your own colors!
this.cameras.main.flash(250, 255, 80, 0);
A white flash is great for big, dramatic moments. A tinted flash can hint at damage type — but again, that’s a creative choice for you to explore, not a rule from the docs.
Stack them: a hit handler that does both
Here’s where the two effects become more than the sum of their parts. Individually, a shake or a flash is a nice touch. Together, they give two cues at once: the frame wobbles and the screen pulses. Layering small feedback effects like this is what game juice is about — each layer is modest on its own, but stacked they make an action feel stronger.
Here’s a complete hit handler you can copy into your Phaser scene class:
onHit() {
this.cameras.main.shake(100, 0.05);
this.cameras.main.flash(250, 255, 255, 255);
}
// Call this.onHit() from wherever your hit/collision logic already lives —
// for example, inside the function that handles damage when your
// player's attack overlaps an enemy.
Notice that the handler is a scene method, so this points at the scene and this.cameras.main resolves correctly. The camera effects don’t care how your collision detection works. Wherever your game already decides “a hit just happened” (an overlap callback, a damage function, anything), that’s where you call this.onHit(). The comment marks the spot.
Both calls are made in the same function, so the shake and flash start together. That overlap is the point: the player perceives one combined moment of impact rather than two separate effects.
A one-line AI-assistant prompt, if you’re building with AI tools: “Add this.cameras.main.shake() and this.cameras.main.flash() calls to my damage-handler function.” Paste that into your assistant along with your existing code, and it can wire the handler in for you.
The callback: what runs every frame
Both shake() and flash() accept a callback parameter. The docs are specific about the shake callback: it is “invoked every frame for the duration of the effect. It is sent two arguments: A reference to the camera and a progress amount between 0 and 1.” The docs don’t describe the flash callback’s timing, so don’t assume it matches.
That progress value is handy — it tells you how far through the effect you are, from 0 (just started) to 1 (finished). Here’s a minimal demo that logs it:
this.cameras.main.shake(100, 0.05, false, (camera, progress) => {
console.log(progress); // a value between 0 and 1
});
You don’t need a callback to use these effects — most of the time you won’t touch it at all. But knowing it exists opens doors later: you could use the progress value to drive some other visual that ramps up and down in sync with the shake. For now, just be aware the hook is there.
Stop, reset, and the completion events
Sometimes you need an effect to stop now — say, a fade is stuck on screen or a shake outstayed its welcome. That’s what resetFX() is for. In the docs’ wording, it “Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to remove the fade.”
this.cameras.main.resetFX();
One call, all active camera effects cleared. Keep it in your back pocket for scene transitions and edge cases.
It’s also worth knowing that each effect announces itself through events. The shake effect fires SHAKE_START and SHAKE_COMPLETE, and the flash effect fires FLASH_START and FLASH_COMPLETE. You don’t need to listen to any of them to use the effects, but when you later want something to happen exactly when a flash ends — a follow-up animation, a state change — those events are the official hooks. (The docs name the events but don’t document listener code on the Camera page, so we’ll leave the how-to for a future post.)
Shake vs. flash vs. fade — quick comparison
The camera’s effect family has a third member worth knowing about: fade. The docs list fade, fadeIn, fadeOut, and fadeFrom variants, all defaulting to a duration of 1000 ms. Where flash snaps to a color instantly and fades away quickly, a fade is the slower, scene-transition tool — think “screen goes to black, new level loads, screen fades back in.” A typical fade-out call:
// Uses the documented default duration of 1000 ms
this.cameras.main.fadeOut(1000);
So when do you reach for which? Shake is for impact — hits, explosions, anything physical. Flash is for emphasis — a moment you want the player’s eye to catch immediately. Fade is for transitions — moving between scenes or states. All three live on the same camera and can be combined, but they answer different design questions.
If you’re also working on how the camera moves — smoothly following the player, deadzones, lerp — check out our related post on that side of the API: Phaser camera follow, lerp, and deadzone.
Common beginner mistakes
A few easy traps to sidestep:
- Calling the effect on the wrong object. These are camera methods. They live on
this.cameras.main(or whichever camera you’re using). If you find yourself trying to call.shake()on a sprite or the scene itself, that’s the bug. - Assuming different defaults. The documented defaults are shake at 100 ms with intensity 0.05, and flash at 250 ms with color 255, 255, 255. If a tutorial or an AI suggestion uses other numbers, those are custom choices, not Phaser defaults — which is fine, just know which is which.
- Forgetting
resetFX()after a fade. The docs specifically call out that resetFX is useful after a fade “in order to remove the fade.” If a scene transition leaves your screen tinted, this is the fix. - Expecting shake to pause the game. The docs describe shake purely as shaking the camera over a duration. They say nothing about pausing or slowing anything, so if you need a pause, build it yourself.
FAQ
Does camera shake pause or slow down the game?
No, the docs don’t say it does. The Phaser Camera docs describe shake as shaking the Camera by the given intensity over the duration specified, and they don’t mention pausing or slowing the game, hit-stop, or time scaling. If you need a pause, add one in your own game loop; the camera shake itself is a visual wobble.
How do I cancel or clear an effect early?
Call this.cameras.main.resetFX(). Per the docs, it “resets any active FX, such as a fade, flash or shake,” and it’s noted as useful to call after a fade in order to remove the fade. One call clears whatever camera effects are currently active.
What’s the difference between flash and fade?
Flash sets the camera to the given color immediately and then fades it away again quickly over the duration — 250 ms by default, in white (255, 255, 255). Fade effects default to 1000 ms and come in several forms: fade, fadeIn, fadeOut, and fadeFrom. In practice, flash reads as an instant emphasis pulse, while fades are the slower transitions used between scenes.
What you learned
- Phaser cameras have built-in special effects — Fade, Flash, and Camera Shake — ready to call on
this.cameras.main. shake(duration, intensity)defaults to 100 ms and 0.05, and works with no arguments at all. Intensity may be a number or aPhaser.Math.Vector2.flash(duration, red, green, blue)defaults to 250 ms in white (255, 255, 255): it sets the camera to the color immediately, then fades away quickly.- Both effects fire events — SHAKE_START/SHAKE_COMPLETE and FLASH_START/FLASH_COMPLETE — and the shake callback runs every frame, receiving the camera and a progress value between 0 and 1.
resetFX()clears any active fade, flash, or shake.- “Game juice” is the practice of layering small feedback effects — shake, flash, particles, sound — on top of an action so it feels as strong as it is mechanically.
Start with the defaults, tune from there, and read the full Phaser Camera docs when you’re ready for the rest of the effects family.