Yes you should be able to use animate to do such a thing. It will probably be much easier when I (eventually) make the new version of animate available, since that allows for timeline animations. I also went ahead and put this module together as well.. could be used with text or other objects and has an optional fade in and fade out duration. Not on my github just yet, but you can just copy the text into /modules/showfade.nut and follow the instructions:
/modules/showfade.nut:
//////////////////////////////////////////////////
//
// Description:
// ShowFade will display an object for a specified length of time, with an optional fade in and fade out.
// Object is displayed at Transition.StartLayout, Transition.ToNewSelection and Transition.ToNewList.
//
// Usage:
// fe.load_module("ShowFade");
// local text = fe.add_text( "[Title]", 0, 0, fe.layout.width, 30 );
//
// local fade_text = ShowFade(text);
// fade_text.fade_in = 0;
// fade_text.show_duration = 3000;
// fade_text.fade_out = 1500;
//
///////////////////////////////////////
class ShowFade
{
fade_in = 750;
show_duration = 5000;
fade_out = 750;
is_fading = false;
last_time = 0;
ref = null;
constructor( obj )
{
ref = obj;
fe.add_transition_callback( this, "on_transition" );
fe.add_ticks_callback( this, "on_tick" );
}
function on_transition( ttype, var, ttime )
{
switch( ttype )
{
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.ToNewList:
if ( ref == null ) ::print("ShowFade: warning: object is null!\n");
is_fading = true;
last_time = get_time();
break;
}
return false;
}
function clamp ( value, min, max ) {
if (value < min) value = min; if (value > max) value = max; return value;
}
function get_time()
{
return ::clock() * 1000;
}
function on_tick( ttime )
{
if ( is_fading )
{
local elapsed = get_time() - last_time;
local duration = fade_in + show_duration + fade_out;
local progress = elapsed / duration.tofloat();
local in_progress = fade_in / duration.tofloat();
local out_progress = ( fade_in + show_duration ) / duration.tofloat();
local alpha_progress = 0;
if ( progress > out_progress )
{
//fade_out
alpha_progress = clamp( 1.0 - ( progress - out_progress ) / ( 1.0 - out_progress ), 0.0, 1.0 );
} else if ( progress > in_progress )
{
//waiting
alpha_progress = 1.0;
} else
{
//fade_in
alpha_progress = clamp( 1.0 - ( in_progress - progress ) / in_progress, 0.0, 1.0 );
}
if ( ref != null ) ref.alpha = alpha_progress * 255;
if ( progress >= 1.0 )
{
is_fading = false;
if ( ref != null ) ref.alpha = 0;
}
}
}
}