Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Oomek on February 25, 2017, 06:26:29 PM
-
I'm looking for a way to play an animation (game list slide-in) but just once when the key/joy is pressed and held.
The event Transition.EndNavigation works fine for slide-out, but I cannot find any equivalent event to do the fade-in.
Is it possible to do with the current api or I would need some new Transition.StartNavigation event to do that?
-
I could do it like this:
local move_gameListBoxFadeIn = {
onStart = function( anim ) { if ( listbox_hidden == true) { time = 250; listbox_hidden = false; }
else { time = 0; } },
wait = true,
when = Transition.ToNewSelection, property = "x", start = flx*0.822, end = flx*0.51, tween = Tween.Expo
}
local move_gameListBoxFadeOut = {
onStop = function( anim ) { listbox_hidden = true },
when = Transition.ToNewSelection, property = "x", start = flx*0.51, end = flx*0.822, time = 250, delay=2000, tween = Tween.Expo
}
but the AM is shouting at me for using wait = true. Is there any other way of doing it?
edit: The main problem here is that onStart is not beeing called if the animation is triggered again before the first run finishes.
-
Anyone? Plz? I'm stuck with my theme... :(
-
AM is not shouting at you about using wait, the animate module is.. wait is ok, as long as you don't mind not being able to use key presses during that time..
Transition.StartLayout and/or Transition.ToNewList is probably what you want:
https://github.com/mickelson/attract/blob/master/Layouts.md#add_transition_callback
You may also want to check var for those as well in your if statement, depending on your use case.
if you do need to use onStart, you can set restart for the animation to false in the options - this will prevent it from restarting an animation if it is already running... check out some of the options in PropertyAnimation:
https://raw.githubusercontent.com/liquid8d/attract-extra/master/modules/animate/property.nut
-
Thank you, "restart = false" did the trick.