Intro screen question - fading titles

Started by , Thu 05/01/2006 20:26:49

Previous topic - Next topic

Uthgar

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. :'(

ManicMatt

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?

DoorKnobHandle

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):
Code: ags

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:

Code: ags

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:

Code: ags

// 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!

SMF spam blocked by CleanTalk