Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: jedione on May 18, 2020, 05:43:22 PM

Title: start layout transition?
Post by: jedione on May 18, 2020, 05:43:22 PM
so what im trying to do is

when theme starts, it is automatically passed one signal , prev_game" or  "next_game"

because all my animations are set to, Transition.ToNewSelection`

not `Transition.StartLayout`


if any one can do this, or knows a work around......thanks
Title: Re: start layout transition?
Post by: sickle on May 18, 2020, 09:05:10 PM
try changing this:
Code: [Select]
if (ttype == Transition.StartLayout){
to:
Code: [Select]
if (ttype == Transition.StartLayout || Transition.ToNewSelection){
"||" means either true if StartLayout or ToNewSelection are true

or, if you want an easier fix, just add:
Code: [Select]
fe.add_transition_callback( this, whenStart )
function whenStart ( ttype, var, transition_time )
{
if (ttype == Transition.StartLayout)
{
fe.signal("next_game")
}
}

(found this info here https://developer.electricimp.com/squirrel/squirrel-guide/operators)
Title: Re: start layout transition?
Post by: jedione on May 19, 2020, 06:39:20 AM
i tryed

fe.add_transition_callback( this, whenStart )
function whenStart ( ttype, var, transition_time )
{
if (ttype == Transition.StartLayout)
{
fe.signal("next_game")
}
}

does not seem to work,  ,,,   it says "the the index 'whenStart' does not exist"
so i added "local whenStart;     

and now it doesent throw that "whenStart' does not exist"      but doesent do anything,
Title: Re: start layout transition?
Post by: sickle on May 19, 2020, 09:46:53 AM
maybe try putting fe.add_transition_callback after the whenStart function:

Code: [Select]
function whenStart ( ttype, var, transition_time )
{
if (ttype == Transition.StartLayout)
{
fe.signal("next_game")
}
}
fe.add_transition_callback( this, whenStart )

did you try the  (ttype == Transition.StartLayout || Transition.ToNewSelection)?
Title: Re: start layout transition?
Post by: jedione on May 19, 2020, 12:37:55 PM
ill try when i get home from work,,  thanks for your help....
Title: Re: start layout transition?
Post by: beccobunsen on May 19, 2020, 03:55:07 PM
You can try a much simpler approach..


Code: [Select]

local your_animation_on_old_or_new = {
when = Transition.FromOldSelection,
property = "x",
start = flx*0.294,
end = flx*0,
time = 0

}

local your_animation_on_StartLayout = {
when = Transition.StartLayout,
property = "x",
start = flx*0.294,
end = flx*0,
time = 0

}



animation.add( PropertyAnimation( your_object, youranimation_on_old_or_new) );
animation.add( PropertyAnimation(  your_object, youranimation_on_StartLayout) );

Title: Re: start layout transition?
Post by: jedione on May 20, 2020, 06:40:08 AM
function whenStart ( ttype, var, transition_time )
{
if (ttype == Transition.StartLayout || Transition.ToNewSelection)
{
fe.signal("next_game")
}
}
fe.add_transition_callback( this, whenStart );

not working,  for me..    this method would work best,  if it can work,   
Title: Re: start layout transition?
Post by: sickle on May 20, 2020, 07:18:51 AM
try just replacing any previous
Code: [Select]
.StartLayout transitions with

Code: [Select]
Transition.StartLayout || Transition.ToNewSelection
do this to all transitions you want to apply this to
Title: Re: start layout transition?
Post by: sickle on May 20, 2020, 10:39:15 AM
You can try a much simpler approach..


Code: [Select]

local your_animation_on_old_or_new = {
when = Transition.FromOldSelection,
property = "x",
start = flx*0.294,
end = flx*0,
time = 0

}

local your_animation_on_StartLayout = {
when = Transition.StartLayout,
property = "x",
start = flx*0.294,
end = flx*0,
time = 0

}



animation.add( PropertyAnimation( your_object, youranimation_on_old_or_new) );
animation.add( PropertyAnimation(  your_object, youranimation_on_StartLayout) );


yeah, that would work too