Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Thu 05/01/2006 20:26:49

Title: Intro screen question - fading titles
Post by: on Thu 05/01/2006 20:26:49
I am making an intro for my game and i'm just wondering how to make a my title fade in and out while character walks across the screen. please help. :'(
Title: Re: Title question
Post by: ManicMatt on Thu 05/01/2006 21:17:03
Hmmm..... I bet Ashen, dkh or strazer could provide a brilliant answer, but I'm going to try until then!

If I were doing it, I'd make the title itself an animating object, or heck even a character, rather than an actual background. I don't know how well you know how to use ags to do that?
Title: Re: Title question
Post by: DoorKnobHandle on Thu 05/01/2006 21:41:39
Quote from: ManicMatt on Thu 05/01/2006 21:17:03
I bet Ashen, dkh or strazer could provide a brilliant answer, but I'm going to try until then!

I'll take that as a challenge! ;D

No seriously, you'd need to make it an object as ManicMatt said - then do the following:

First copy this function into the beginning of your global script (CTRL+G):

function fade_object ( Object *_object, FADE_TYPE type )
// gradually fades an object in or out
{
int counter;

if ( type == IN )
// if we are fading the object in
{
// set everything up
counter = 100;
_object.Transparency = 100;
_object.Visible = true;

while ( counter > 0 )
// fade it in
{
counter--;
_object.Transparency = counter;
Wait ( 1 );
}
}
else if ( type == OUT )
// if we are fading the object out
{
// set everything up
counter = 0;
_object.Transparency = 0;
_object.Visible = true;

while ( counter < 99 )
// fade it out
{
counter++;
_object.Transparency = counter;
Wait ( 1 );
}

// now mark the object as invisible
_object.Visible = false;
}
}


Now switch to the script header (CTRL+H) and add the following lines:


enum FADE_TYPE
{
IN,
OUT
};

import function fade_object ( Object *_object, FADE_TYPE type );


Now you have everything set up. You only need to use the new commands: To do this, please go to the room with the title as object. Name the title something like "logo", so that the script-o-name is "oLogo". Now go to "Room->Settings" and click on the button with the red "i" on it. Next double-click on "Player enters screen (after fadein) and select "Run script" from the drop-down menu. Then click on the "Edit script..." button and type the following:


// fade the title in
fade_object ( oTitle, IN );

// move the player character
player.Walk ( 100, 100, eBlock );

// then fade the title out again
fade_object ( oTitle, OUT );


Feel free to ask questions on how certain parts of the script work and make sure you use AGS version 2.7 or higher!