Author Topic: video not visible after from game transition  (Read 5061 times)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
video not visible after from game transition
« on: July 06, 2016, 03:38:16 PM »
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.

Code: [Select]
// 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;
}

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: video not visible after from game transition
« Reply #1 on: July 06, 2016, 08:28:12 PM »
I never figured out the issue with the boot video not visible after coming from a game. However, I figured out that I can send a reload signal and all is well with the cosmos. I cleaned up the code so the class itself can add ticks and callbacks that point to itself. The secret was using „this“ as an environment object.

Here’s the revised code if anyone wants to take a peak. Should make it’s way into mvscomplete layout soon. I must say, I am not the best designer - nor coder, but this is coming along to be a really cool project. Loving attract mode. Can’t wait to get it up on the crt.

Code: [Select]
// 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;
   
    fe.add_ticks_callback( this, "End" );
    fe.add_signal_handler( this, "Block" );
    fe.add_transition_callback( this, "Reload" );
  }
 
  // public functions

  function Play() {
    video.visible = true;
    video.video_playing = true;
    Mute();
  }
 
  // private functions
 
  function Mute() {
    if ( video.video_playing == true ) {
      if ( background != null ) background.video_flags = Vid.NoAudio;
    }
    else {
      if ( background != null ) background.video_flags = Vid.Default;
    }
  }
 
  function End( ttime ) {
    if ( video.video_playing == false ) {
      video.visible = false;
      Mute();
    }
    return false;
  }
 
  function Block( signal ) {
    if (( video.video_playing == true ) && ( signal != null )) return true;
    return false;
  }
 
  function Reload( ttype, var, ttime ) {
    switch ( ttype ) {
      case Transition.FromGame:
        fe.signal( "reload" );
        break;
    }
    return false;
  }
}

local boot = Boot("intro/boot.mp4");
boot.Play();