Layout will be contained to 4:3 format. Using a surface because the fe object allows child objects to be shown outside of itself. Boot video (a recording of the neo geo boot screen) is intended to be played when the layout starts and coming from a game.
I created a boot class, with a constructor, play and stop methods. The object could potentially call its own stop method, but I can not find a way for squirrel to sleep/wait/timer. So, I am using the fe.add_ticks_callback to see if the video is not playing and call the stop method on the boot class. It probably waste cpu resources, but it’s the only way I could think of how to do it. Is there a better way?
I am using fe.add_transition_callback method to call the start method on the boot class when ttype is Transition.StartLayout or Transition.FromGame. Currently, It works when the layout is first started. After exiting a game, background is frozen and muted, and audio from boot video can be heard, but it is not visible. The same result occurs in mac 10.11 and windows 7 running attract 2.1. Any ideas of why it is not visible? zorder has no effect. I don’t even think zorder works because I can give the video a zorder of 1000 and it is not visible at any time unless its drawn after the background.
// Attract-Mode front end
// mvscomplete layout by keilmillerjr
// http://keilmiller.com
fe.load_module( "fade" );
fe.load_module( "conveyor" );
//
// Screen
//
fe.layout.width = 640;
fe.layout.height = 480;
fe.layout.preserve_aspect_ratio = true;
local screen = fe.add_surface( 640, 480 );
//
// Background
//
local bgx = (640/8)*-1;
local bgy = (480/8)*-1
local bgw = (640/4)*5;
local bgh = (480/4)*5;
local background = FadeArt( "snap", bgx, bgy, bgw, bgh, screen );
//
// Boot
//
class Boot {
video = null;
constructor( path ) {
video = screen.add_image( path, 0, 0, 640, 480 );
video.visible = false;
video.video_playing = false;
video.video_flags = Vid.NoLoop;
}
function Play() {
if ( background != null ) background.video_flags = Vid.NoAudio;
video.visible = true;
video.video_playing = true;
}
function Stop() {
video.visible = false;
if ( background != null ) background.video_flags = Vid.Default;
}
}
local boot = Boot("intro/boot.mp4");
fe.add_ticks_callback( "boot_tick" );
function boot_tick( ttime ) {
if ( boot.video.video_playing == false ) {
boot.Stop();
}
return false;
}
fe.add_transition_callback( "transitions" );
function transitions( ttype, var, ttime ) {
switch ( ttype ) {
case Transition.StartLayout:
case Transition.FromGame:
boot.Play();
break;
}
return false;
}