Author Topic: [HELP] Delay to start snap  (Read 200 times)

arthurvalenca

  • Full Member
  • ***
  • Posts: 47
    • View Profile
[HELP] Delay to start snap
« 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 );

iOtero

  • Sr. Member
  • ****
  • Posts: 327
    • View Profile
Re: [HELP] Delay to start snap
« Reply #1 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.
I love that on my laptop the eyes shine to the Alien every time i access the ssd... :D

8bitsdeep

  • Full Member
  • ***
  • Posts: 43
    • View Profile
Re: [HELP] Delay to start snap
« Reply #2 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");
}