WilderLand

Has anyone come up with a nice slick class that does simple fade-in and fade-out to black screen transitions I started working on one and it continues to get more complicated and was curious if anyone else had already done this. If you have are you willing to share your code, or explain how you approached it

Thanks.

Mike



Re: XNA Game Studio Express How to do a screen fade?

dczraptor

I've been wondering about this too. It'd be nice to have some screen effects to enhance the overall feel of my game. The only way that I personally know is to use a full-screen sprite and change the alpha value. I haven't actually implemented this, but it is probably not the best way and it's probably slow. I'd like to know if anybody came up with a good way too.




Re: XNA Game Studio Express How to do a screen fade?

Shawn Hargreaves - MSFT

Drawing a fullscreen sprite is the perfect way to do this, and will be extremely fast.





Re: XNA Game Studio Express How to do a screen fade?

George Clingerman

I do have an example of fading sprites if anyone needs it. It's pretty basic, but the effect is basically the same.

You can find the tutorial and source code here.






Re: XNA Game Studio Express How to do a screen fade?

Shinzo-Prime

My solution would be to render the whole scene to a texture an render the texture with 2 triangles to screen. With the color variables of the triangle vertices you could change the overall color of the scene (fade to black, fade to red for hits). This technique also allows you to apply realtime fullscreen HLSL effects like grain, glow or blur.




Re: XNA Game Studio Express How to do a screen fade?

IG Fats

I was working on something like this this weekend. I'm only writing a 2D game, but if you're using a 2D HUD over the top of your 3D stuff, it should still be useful.

I created a "Transition" class that contains an alpha colour, a target alpha colour, a transition speed and a title.

I then create a new transition for each sprite that I wish to use a fade effect on, and give it a title (ie "titlescreen"), and an initial colour and a speed. I then add that transition to a collection.

When I wish to begin the fade, I simply find the transition by title, and set the target colour to either full alpha or no alpha, depending on which way I want it to fade. The update code handles increasing or decreasing the alpha colour by the speed to fade it in or out.

Then, when I draw the sprite I'm transitioning, I find the transititon by title once again and use the transition.colour as the sprite's colour.

I've packaged up my project as it currently stands, let me know if anyone finds it useful :)







Re: XNA Game Studio Express How to do a screen fade?

WilderLand

Both of the examples provided fade individual sprites, which at this point would require a lot of re-work in my code to go this route. I just want to fade out the entire screen, regardless what what sprites ae on it. I think Shawn's suggestion is the way to do this, but I'm not sure how to implement that properly. Has anyone does this sort of thing





Re: XNA Game Studio Express How to do a screen fade?

WilderLand

I figured this one out on my own. If you look here there is actually an example of the full screen sprite method of fading the screen. Although the example is beta 1, it is pretty easy to modify it to suit what ever you would need.

Mike