Make a picture fade in

Started by Lufia, Mon 12/10/2009 18:59:57

Previous topic - Next topic

Lufia

So, I'd like to make a picture fade in on top of the background of a room and later fade out. I first thought of using an Overlay but I didn't see anything about setting transparency for these. So then I looked at DrawingSurface. And I found that :

QuoteTIP: If you want to gradually fade in a second background, create a copy of the original surface and then restore it after each iteration, otherwise the backgrounds will converge too quickly.

lol wut?
Iterations of what ?

Thanks for your help.

Ryan Timothy B

By picture, do you mean a picture frame which is hanging on a wall?  Or a picture GUI that pops up over top everything in the screen?

If it's the first, use an object and set it's transparency.
You'd be using a while loop so it could fade in.  Something like this (copied from the manual):
Code: ags

int trans = object[0].Transparency;
while (trans > 0) {
  trans--;
  object[0].Transparency = trans;
  Wait(1);
}



But if it's a picture that pops up over all characters, objects, and the background, I would use a GUI.
Make a GUI with a background picture whatever you're doing (or if this is something that happens with multiple objects or whatever, you could use a Button and just change the graphic each time it is to be displayed).
Copied from the manual:
Code: ags
int trans = gNameOfGUI.Transparency;
while (trans > 0) {
  trans--;
  gNameOfGUI.Transparency = trans;
  Wait(1);
}

Lufia

Thankies.

I'll go down the GUI road, it's used all over the game to make my dialogs look all pretty. I wont bother with a button, though, setting myGui.BackgroundGraphic should work just as well.

Still, I wonder what means the sentence I quoted from the manual? Is there a way to make a fade in using DrawingSurface or not? As a side note, I don't really get what Overlays would be useful for, their properties seem rather limited.

Ryan Timothy B

One of the best examples for using the DrawingSurface for a fade in/out, would be a background going from daytime to night (or the other way around).  Having it fade from the one colored background to another.  Just makes a nice smooth transition to show a time lapse.

Although there are many many possibilities for a DrawingSurface crossfade.


QuoteI'll go down the GUI road, it's used all over the game to make my dialogs look all pretty. I wont bother with a button, though, setting myGui.BackgroundGraphic should work just as well.

One issue I can see with changing the BackgroundGraphic (which to tell you the truth, I didn't know was possible. thanks), would be if you have different sized 'pictures' to be placed.  You'd have to reposition the whole GUI to center for the different sized picture.  But with a Button, you could just make the GUI the whole size of the screen and just change the Button graphic and adjust the Button to be placed in the center based on Button.Width and Button.Height.

But if all the images are the same size just stick with the BackgroundGraphic. :P

SMF spam blocked by CleanTalk