Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: mahuti on March 14, 2017, 04:42:09 AM

Title: Display an image after game quit
Post by: mahuti on March 14, 2017, 04:42:09 AM
Is there a script floating around to display a game over image after you quit a game? I started messing with a script with transition.fromgame (and it works) but it's too fast. Before I start investigating all the properties and methods, I was curious if there was a "known" script out there that does this already.
Title: Re: Display an image after game quit
Post by: keilmillerjr on March 14, 2017, 06:59:40 AM
See my thread here (http://forum.attractmode.org/index.php?topic=1302.msg10194#msg10194).

I attempted to create a loading video plugin. However, a true loading screen is impossible because attract mode doesn’t load emulators in the background. I was having video issues because I had to keep redrawing the screen to prevent attract mode from leaving to the game.

This code can easily be adopted to create a game over screen, and it would work without an issue. I can modify it for you when I get a chance and add a fade out. You would have to make sure you turn off audio for all other objects. Blocking key presses might be a good idea too.
Title: Re: Display an image after game quit
Post by: qqplayer on March 14, 2017, 10:56:11 AM
I made some test , maybe this will help you:

Code: [Select]
::OBJECTS <- {
 FadeOut = fe.add_artwork("FadeOut", flx*0, fly*0, flw, flh ),
}

local alpha_transition = {
    when = Transition.FromGame ,property = "alpha", start = 0, end = 255, time = 500, easing = Easing.Out, wait = true,
 }

animation.add( PropertyAnimation( OBJECTS.FadeOut, alpha_transition ) );
[code]
Title: Re: Display an image after game quit
Post by: mahuti on March 16, 2017, 07:06:20 AM
Here's what I ended up using. I considered using a callback in the first transition to call the second, but didn't feel like doing further testing.

This gives a 5 second static shot, and then 1/2 second fade.

In several of the examples I saw here and there on this site, animation.add() was used, without noting that the "animate" module needed to be loaded. Once I added that, my stuff started working.

Thanks for your help guys. Couldn't have got there without you.

Code: [Select]
fe.load_module("animate"); // load this to use the animation methods.
::OBJECTS <- {
 GameOver = fe.add_image("game_over.png",  xpos(0), ypos(0), width(base_width), height(base_height) ),
}
OBJECTS.GameOver.alpha=0; // set to 0 to hide until needed.

local static_transition = {
    when = Transition.FromGame,
property = "alpha",
start = 255,
end = 255,
delay = 0,
time = 5000,
 }
 local alpha_transition = {
    when = Transition.FromGame,
property = "alpha",
start = 255,
end = 0,
delay = 5000,
time = 500,
easing = Easing.In,
 }
animation.add( PropertyAnimation( OBJECTS.GameOver, static_transition ) );
animation.add( PropertyAnimation( OBJECTS.GameOver, alpha_transition ) );