Fade to white effect - room transition interference

Started by Intangible, Mon 20/06/2011 16:21:49

Previous topic - Next topic

Intangible

I need a "fade to white" effect in my game, preferrably for reuse but at least for an explosion effect. The method that triggers the explosion effect looks like this:

function ExplodePlayer(const string deathMessage)
{
  ShakeScreen(3);
  SetFadeColor(255, 255, 255);
  FadeOut(2);
  player.Transparency = 100;
  Wait(1);
  SetNextScreenTransition(eTransitionInstant);
  player.ChangeRoom(303);
}

...and room 303's "AfterFadeIn()" event looks like this:

function room_AfterFadeIn()
{
  FadeIn(2);
  SetFadeColor(0, 0, 0);
  PromptDeath("This game can just blow you away sometimes!");
}


Room 303 is a completely black room. The code's goal is that you'll get a screen shake, a fade to white, and when the fade clears you're staring a black screen which will prompt you with a "death message". I initially tried to accomlish this with the "room change" transition itself (which is a fade), but the "room change" fade was much to quick and I couldn't find a way to control its speed. So, I tried manually taking control of the fade effect by using FadeOut() and FadeIn() commands, and making the transition itself instant. This almost works... except that, annoyingly enough, there is still just the slightest flash of black at the peak of the white fade transition (I guess even an instant "room change" transition can interrupt the appearance of FadeOut()/FadeIn() for a very brief period).

I did a little searching on the forums, and one person suggested making the "destination" room itself white at the start, and then fade it to black after the room loads. I can certainly do that, but before I do a lot of extra work, I need to ask... is there a better way I could be doing this? I might want to use the "fade to white" trick for more than just the explosion, so I was hoping I could accomplish it fairly "natively" in AGS without a lot of custom code.

Intangible

Wow... I have to say I'm impressed. I've asked quite a number of questions on these forums, and this is the first time I've ever had to wait a few days for an answer. :)

Well, it isn't a big deal if there isn't a good way to do this right now. For the time being it's an isolated case, so it doesn't have to be perfect.

Khris

You kind of already posted the answer in your first post.
Making the background white doesn't sound like a lot of extra work.

BlueAngel

I dont know if this can help you but have you looked att the Tween Module and maybe use a black gui over the whole screen and fade it?

monkey0506

A GUI or perhaps just two room objects (one for each room) would serve the purpose well enough. I'm actually making extensive use of objects for fading in my upcoming game, and the level of control is rather nice. I specifically need the player to be able to be moved in front of the faded area (a la narrator), but if you don't need that then a GUI would suffice.

And if you're really concerned about the horrors of having to create a sprite externally:

Code: ags
DynamicSprite *sprite = DynamicSprite.Create(Room.Width, Room.Height);
DrawingSurface *surface = sprite.GetDrawingSurface();
surface.Clear(15);
surface.Release();
// GUI method:
gFader.BackgroundGraphic = sprite.Graphic;
// Room background method:
surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(0, 0, sprite.Graphic);
surface.Release();

Intangible

Quote from: Khris on Thu 23/06/2011 12:33:10
You kind of already posted the answer in your first post.
Making the background white doesn't sound like a lot of extra work.

Fair enough. I just wanted to make sure that I wasn't missing a more "native" way of doing this.

The game I'm working on is basically a 3-room, "proof-of-concept" thing for a larger game I want to make. I'm trying to establish the best ways of doing things in AGS by writing this small game first, so that I don't have to make widespread changes to a larger game later on. If a white/black room is the best way of handling this particular trick, I'm fine with that.  :)

Dualnames

I'm using the tween module and a GUI to do fade effects. And all I do is use FadeEffect.Fade(2.0); to fade in or out. The function "detects" whether to fade in or out. If you're interested in this, I could provide the code with or without the Tween Module.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk