# Camera fading issue?

**URL:** <https://phaser.discourse.group/t/camera-fading-issue/5457>\
**Category:** Phaser 3\
**Created:** [March 9, 2020, 11:28pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457 "2020-03-09T23:28:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [March 9, 2020, 11:28pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/1 "2020-03-09T23:28:58Z")

</div>

so i’m trying to get my camera to fade to black, then reset the scene WITHOUT going back to the scene first. how do i instead of this flickering from black back to the scene, make it so it fades to black, restarts the scene & THEN fades back into the game? for some reason, this does a thing where it fades to black, waits a second or 2, goes to the scene, then runs the scene like normal after 2 seconds of waiting?

```javascript
// `Shake` the Camera to show `death`

__camera.shake ( 100, 0.05 );

// `Fade` the Camera out with a 250 millisecond delay

__camera.fade ( 250, 0, 0, 0, false, (__camera, __progress ) => {
    if ( __progress > 0.999 ) {
        __scene.restart ( );
    }
} );

```

ANY help as always is GREATLY appreciated!

Thank You! 🙂

---

<div class="post-metadata">

**Author:** ![cpusam](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/cpusam/32/3136_2.png) [@cpusam](https://phaser.discourse.group/u/cpusam)\
**Post date:** [March 10, 2020, 1:17am UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/2 "2020-03-10T01:17:09Z")

</div>

I make this effect by using a black sprite over the top of scene. And so I chance its alpha, going from 0 ato 1, ou from 1 to 0, depends of what I want, if make black or make clear.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [March 10, 2020, 4:45pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/3 "2020-03-10T16:45:42Z")

</div>

What happens if you restart the scene only (no camera effects)?

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [March 10, 2020, 4:50pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/4 "2020-03-10T16:50:22Z")

</div>

@samme : it doesn’t work the way it’s supposed to. It just resets with no fade.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [March 10, 2020, 4:56pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/5 "2020-03-10T16:56:49Z")

</div>

Yes, but does the scene restart correctly? Is there a delay?

---

<div class="post-metadata">

**Author:** ![Villan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/villan/32/2920_2.png) [@Villan](https://phaser.discourse.group/u/Villan)\
**Post date:** [March 10, 2020, 4:59pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/6 "2020-03-10T16:59:52Z")

</div>

this.time.addEvent({  
delay: 200,  
callback: function(){  
\_\_scene.restart();  
}  
})

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [March 10, 2020, 5:03pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/7 "2020-03-10T17:03:01Z")

</div>

@samme : a split-second delay as far as i can tell.

@Villan : Uncaught TypeError: Cannot read property ‘addEvent’ of undefined

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [March 10, 2020, 5:13pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/8 "2020-03-10T17:13:00Z")

</div>

When you restart a scene, an entirely new main camera is created, with no effects running. That’s normal. You would have to fade in again from there.

I don’t see where a long delay could be coming from. Try adding some logging.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [March 10, 2020, 5:23pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/9 "2020-03-10T17:23:25Z")

</div>

@samme : there is supposed to be a 250 millisecond delay, a black fade out, a scene fade in then a scene reset.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [March 10, 2020, 5:24pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/10 "2020-03-10T17:24:03Z")

</div>

```javascript
__camera.fade ( 250, 0, 0, 0, false, (__camera, __progress ) => {
	if ( __progress > 0.999 ) {
		__scene.restart ( );
	}
} );

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [March 10, 2020, 6:42pm UTC](https://phaser.discourse.group/t/camera-fading-issue/5457/11 "2020-03-10T18:42:56Z")

</div>

Here is camera fade out, restart, fade in:

https://codepen.io/samme/embed/preview/qBdpeVP?height=300&slug-hash=qBdpeVP&default-tabs=js,result&host=https://codepen.io

From the code you’ve shown, I don’t see where a 1 or 2 second delay could be coming from. Add some logging. You need to figure out what the scene is actually doing during that time.
