I've noticed with a couple of emulators I'm using (Mednafen via RetroArch, for example) sometimes it takes a considerable amount of time to start, and the Attract interface just appears locked during that time. I'd like to be able to fade down the interface before the initiating the emulator call to provide a little bit of feedback that something is happening instead of it looking like Attract has frozen
So far I have code that looks like this:
function drawVeil() {
log("Drawing veil");
local veil = fe.add_image("veil.jpg", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
veil.alpha = 0;
//fade in animation
local fadeInVeil = {
when = Transition.ToGame,
property = "alpha",
start = 0,
end = 255,
time = L_CONF.TRANSITION_VEIL_FADE_ANIM_DURATION,
onStart = function(anim) {
log("fading in veil");
}
}
//fade in animation
local fadeOutVeil = {
when = Transition.FromGame,
property = "alpha",
start = 255,
end = 0,
time = L_CONF.TRANSITION_VEIL_FADE_ANIM_DURATION
}
animation.add( PropertyAnimation(veil, fadeInVeil) );
animation.add( PropertyAnimation(veil, fadeOutVeil) );
function toFromGameTransition( ttype, var, transition_time )
{
switch(ttype) {
case Transition.ToGame:
log("ttime " + transition_time);
break;
}
}
fe.add_transition_callback("toFromGameTransition");
}
The problem is that the hand off to the emulator happens immediately before the fade in can happen. I have a Transition callback in place, and I was hoping I could add something in there to delay the hand off in order to give the UI enough time to update (i.e. complete fading in the veil).
1) I can't figure out what the function call is to create a timer in squirrel. I'm looking for the equivalent of javascript's setTimeout function.
2) How do I first cancel the handoff, then reinitiate it after the timer fires?
3) Is there a better approach to achieve what I'm after?
All help is appreciated.
Thanks!
- Jeff