Screen Fades and Audio playback

BlitzMax Forums/BlitzMax Beginners Area/Screen Fades and Audio playback

Rico(Posted 2008) [#1]
Please would someone tell me how to (if its not too hard)

1 - Fade a screen to black
2- Fade a screen to white
3 - start playback of a sound part way through e.g. specify the position

Thank you very much.


MGE(Posted 2008) [#2]
Best way to do a screen fade is draw a rect Setcolor 0,0,0 the full width of the screen with a varying Alpha level. Works like a charm except for a small rendering hit. ;)


Grey Alien(Posted 2008) [#3]
Agreed. No idea on the sound thing though...


Grisu(Posted 2008) [#4]
you can play "parts" of a file via fmod if that is an option?


Rico(Posted 2008) [#5]
Thank you very much Grey Alien and MGE - Does the screen fade work for fading to white too?

Grisu - I have fmod - but I didn't realise I could play parts of a file. I found a command to Get the current position but not to set it - what command do I need to use? (I will check the documenatation again anyway because I probably missed it)

Thank you everyone!


JazzieB(Posted 2008) [#6]
Yes, the screen fade thing works for any colour. All you're doing is drawing your screen as usual and then drawing a rectangle of any colour of your choosing on top of it, but varying the alpha level for each frame.

As for the sound thing, there is no way of doing this with the built in audio commands. But, as pointed out, you should be able to do this via FMod or any other third party audio module. I haven't used any of these myself, so can't give you the exact command(s) you need to use.


Yan(Posted 2008) [#7]
As for the sound thing, there is no way of doing this with the built in audio commands.
There is...But it ain't pretty. ;o)


xlsior(Posted 2008) [#8]
Here's some code I put in the Code Archives some time ago:

It can do fade to black, fade to white, as well as a cross-fade from one image to another.



And a somewhat related one: Fade to Monochrome.
Converts a full-color image to a black-and-white version, or desaturate it to a shade in between. (Interesting effect, but much more CPU intensive)




Grisu(Posted 2008) [#9]
For setting the position inside a file I use:
FSOUND_Stream_SetTime(shorttrailer, Value)


Rico(Posted 2008) [#10]
Wow! - Thank you to everyone for all the kind help.

I have tried your screen-fade routine xlsior - they are very good! You are right - the second routine will be very good for when the game is paused.

Grisu and Yan - Thanks for the help with the audio- playback. I will try both methods.