Attract-Mode Support Forum

Attract-Mode Support => General => Topic started by: arthurvalenca on June 22, 2019, 10:46:00 PM

Title: [HELP] Delay to start snap
Post by: arthurvalenca on June 22, 2019, 10:46:00 PM
hello everyone, I need some help to put a delay to start the videos with the surface, someone would have some idea to help me

I'm trying to add the delay in this code:

Code: [Select]
local surface = fe.add_surface( 640, 480 );
local artwork = FadeArt( "snap", 80, 0, 480, 650, surface, );
artwork.trigger = Transition.EndNavigation;
artwork.preserve_aspect_ratio = false;
surface.set_pos( x*0.325, y*0.240, w*0.350, h*0.650 );
Title: Re: [HELP] Delay to start snap
Post by: iOtero on July 05, 2019, 09:16:11 AM
Try this:

Code: [Select]
fe.load_module("animate");

local surface = fe.add_surface( 640, 480 );
local artwork = FadeArt( "snap", 80, 0, 480, 650, surface, );
artwork.trigger = Transition.EndNavigation;
artwork.preserve_aspect_ratio = false;
surface.set_pos( x*0.325, y*0.240, w*0.350, h*0.650 );

local fade = {property = "alpha", start = 0, end = 255, time = 2500, delay = 3500, pulse = true}
animation.add(PropertyAnimation(surface, fade));

I do not know if FadeArt will be compatible with this code (fade.nut vs animate.nut).

If not run, try without FadeArt.
Title: Re: [HELP] Delay to start snap
Post by: 8bitsdeep on July 19, 2019, 11:02:31 AM
If you want more control over the load delay, you can also do it manually. I like adding this to my themes to keep navigation as snappy as possible.  Change "load_timer_max" to however long you want the delay to be in ms. You can also do the same thing to update box art and such manually for the smoothest possible navigation when using a text-based game list.

Code: [Select]
local has_moved = false;
local load_timer_max = 50;
local load_timer = load_timer_max;

////////
// Video
////////
local video = fe.add_image("snap.mp4", 0, 800, 600);
video.preserve_aspect_ratio = true;

////////
// Transitions
///////
fe.add_transition_callback( "my_transition" );
function my_transition( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.ToNewSelection:
has_moved = true;
load_timer = load_timer_max;
break;

case Transition.ToNewList:
case Transition.FromGame:
updateMedia();
break;
}

return false;
}

///////////
//Custom Load Timer
///////////
fe.add_ticks_callback( "updateTick" );
function updateTick( ttime )
{
load_timer = max(0, load_timer-1);

//Update game media after delay
if( has_moved && load_timer == 0)
{
updateMedia();
has_moved = false;
}

}

////////
// Functions
////////
function max(a,b){
if(a > b) return a;
else return b;
}

function updateMedia(){
video.file_name = fe.get_art("snap");
}