Author Topic: Transitions without transitions?  (Read 6307 times)

cools

  • Full Member
  • ***
  • Posts: 83
  • Arcade Otaku Sysadmin
    • View Profile
    • Arcade Otaku
Transitions without transitions?
« on: August 05, 2014, 04:32:46 PM »
Example below displays a list box whilst up/down are being pressed (any way of reading the global key configuration to find out what's in use?), and fades it out when the key is released. We avoid getting trapped waiting for transitions to complete before we can select another game.

Only weirdness is when in the configuration menu - I can't seem to reliably capture a "Tab" event to toggle on a "pause fake transition" part, so it just keeps flashing the menu up (but not moving) when you're in config.

Code: [Select]
local flw=fe.layout.width;
local flh=fe.layout.height;

local gamesurface=fe.add_surface(flw,flh);
gamesurface.alpha=0;
local gamesnap=gamesurface.add_artwork("snap",0,0,flw,flh);
gamesnap.video_flags=Vid.ImagesOnly;
local listsurface=fe.add_surface(flw,flh);
listsurface.add_listbox(0,0,flw,flh);
listsurface.alpha=0;
const LISTTIME=50;
local listtimer=0;

function displaylist (ticks)
{
 if (fe.get_input_state("Up")==true)
 {
  listtimer=LISTTIME;
  listsurface.alpha=255;
  gamesurface.alpha=0;
 }
 else if (fe.get_input_state("Down")==true)
 {
  listtimer=LISTTIME;
  listsurface.alpha=255;
  gamesurface.alpha=0;
 }
 else
 {
  listtimer-=1;
  if (listsurface.alpha>(255/LISTTIME))
  {
   listsurface.alpha-=255/LISTTIME;
  }
  if (gamesurface.alpha<255-(255/LISTTIME))
  {
   gamesurface.alpha+=255/LISTTIME;
  }
 }
}

fe.add_ticks_callback ("displaylist");
« Last Edit: August 05, 2014, 04:49:26 PM by cools »

Luke_Nukem

  • Sr. Member
  • ****
  • Posts: 135
    • View Profile
    • Blogging about Rust lang
Re: Transitions without transitions?
« Reply #1 on: August 15, 2014, 01:17:40 AM »
Hey dude, try this;

Code: [Select]
local flw=fe.layout.width;
local flh=fe.layout.height;

local gamesurface=fe.add_surface(flw,flh);
gamesurface.alpha=0;
local gamesnap=gamesurface.add_artwork("snap",0,0,flw,flh);
gamesnap.video_flags=Vid.ImagesOnly;
local listsurface=fe.add_surface(flw,flh);
listsurface.add_listbox(0,0,flw,flh);
listsurface.alpha=0;
const LISTTIME=50;
local listtimer=0;
local enableList = 0;

fe.add_transition_callback( "displayTransition" );

function displayTransition (ttype, var, ttime ){
switch ( ttype )
{
case Transition.ToNewSelection:
{
if (fe.get_input_state("Up")==true)
{
enableList = 1;
}
else if (fe.get_input_state("Down")==true)
{
enableList = 1;
}
}
}
}

function displaylist (ticks){
  if (enableList == 1){
if (fe.get_input_state("Up")==true)
{
listtimer=LISTTIME;
listsurface.alpha=255;
gamesurface.alpha=0;
}
else if (fe.get_input_state("Down")==true)
{
listtimer=LISTTIME;
listsurface.alpha=255;
gamesurface.alpha=0;
}
else
{
listtimer = (listtimer -1);
if (listsurface.alpha>(255/LISTTIME))
{
listsurface.alpha-=255/LISTTIME;
}
if (gamesurface.alpha<255-(255/LISTTIME))
{
gamesurface.alpha+=255/LISTTIME;
}
if (listtimer <= 0){
enableList = 0;
}
}
}
}

fe.add_ticks_callback ("displaylist");

That is an excellent idea too mate, I'm going to have to incorporate a version of it into one of my layouts.