Attract-Mode Support > General
[HELP] Delay to start snap
(1/1)
arthurvalenca:
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: ---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 );
--- End code ---
iOtero:
Try this:
--- Code: ---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));
--- End code ---
I do not know if FadeArt will be compatible with this code (fade.nut vs animate.nut).
If not run, try without FadeArt.
8bitsdeep:
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: ---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");
}
--- End code ---
Navigation
[0] Message Index
Go to full version