Author Topic: Adding artwork: Forcing it to fade in? Or out?  (Read 693 times)

Asterra

  • Full Member
  • ***
  • Posts: 44
    • View Profile
Adding artwork: Forcing it to fade in? Or out?
« on: June 22, 2017, 03:57:06 AM »
Trying to get the ball rolling on tweaking a theme to better suit the idea of being able to judge a game's worth without having to wait for the video to fade in.  Here are the things I need to ask how they might be done:

1. How to cause an artwork element to fade out at a set rate / over a set amount of time.
2. How to cause an artwork element to fade in at a set rate / over a set amount of time.
3. How to delay either of these operations by a set amount.
4. How to detect whether the video (as opposed to only a screenshot) for a given game is available, so that I can base the followup actions on the result of that query.

And, if it wasn't obvious by now, what I'm trying to do is set things up so that the theme loads the screenshot for a given game immediate, waits for a beat, and then fades it out while fading in the video of the game, if it is available. 

jedione

  • Sr. Member
  • ****
  • Posts: 427
  • punktoe
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #1 on: June 22, 2017, 06:29:34 AM »
here ya go try this,,,

Code: [Select]
fe.load_module("animate");

local pic = fe.add_artwork( "snap", 200, 200, 200, 200 );
local pic_cfg = {
when =Transition.ToNewSelection,
property = "alpha",
start = 255,
end = 0,
time = 4000,
//delay = 5000,
}
animation.add( PropertyAnimation( pic, pic_cfg ) );


local vid = fe.add_artwork( "video", 200, 200, 200, 200 );
local vid_cfg = {
when =Transition.ToNewSelection,
property = "alpha",
start = 0,
end = 255,
time = 3000,
//delay = 3000,
}
animation.add( PropertyAnimation( vid, vid_cfg ) );
help a friend....

Asterra

  • Full Member
  • ***
  • Posts: 44
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #2 on: June 22, 2017, 05:11:16 PM »
here ya go try this,,,
Thanks.  Quite instructive.

Been tinkering with it for a little while.  My next hurdle seems to be this: The delay property doesn't delay the displaying of the element.  This presents two challenges.  First, the video is audibly playing in the background while the screenshot has priority, and that footage is lost to the viewer.  Second, the delay invariably means that there is an unusual conflict between the two elements.  For example, if the video element is called after the screenshot, then the screenshot is not even visible until it begins its fade animation, after the delay.

Obvious solution is to work in an initial alpha setting.  I just don't know the syntax.  It's evidently not simply: vid.alpha = Setting(0)   And I don't have enough examples to pore over in order to glean a better sense, or direct illustration, of how to use it.

jedione

  • Sr. Member
  • ****
  • Posts: 427
  • punktoe
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #3 on: June 22, 2017, 05:33:01 PM »
it's best to wait for liquid8 when he revises the animation mod. should be good.

not shure when it will be...anyway

as of right now it is limited, has delay conflicts, and the wait = true, don't work either ...

help a friend....

Asterra

  • Full Member
  • ***
  • Posts: 44
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #4 on: June 22, 2017, 05:45:10 PM »
it's best to wait for liquid8 when he revises the animation mod. should be good.
Something to look forward to.  But in the meantime, I am confident that my current predicament can be solved if I can figure out how to use the alpha property, as mentioned here:

http://attractmode.org/docs/Layouts.html#Image

I have seen skew_x, skew_y, pinch, rotation etc. used in themes successfully.  I imagine alpha works as intended also, but I simply do not have a handle on what input I am expected to plug in.  The guide in the above link only mentions value, but AttractMode chokes on that, so it seems to want something more.

Edit: Actually I suppose the efficacy of this solution would depend on whether or not the animation module's alpha settings override the initial alpha value...
Edit2: It seems that simply vid.alpha = 0 will pass muster, although it currently does not seem to have any effect whatsoever.  More testing ensues.
« Last Edit: June 22, 2017, 05:51:40 PM by Asterra »

Asterra

  • Full Member
  • ***
  • Posts: 44
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #5 on: June 22, 2017, 06:31:34 PM »
Okay, I worked out a solution.  What I've done is set it up so the video is loaded first, and it does not animate; it simply plays in the background.  Since the video gets played immediately regardless, it really doesn't matter.  The screenshot loads after it, and its alpha animates from 0 to 255 over 1 second, after a 1 second delay.

Now, this works the first time I select a new game.  There after, however, what happens is the screenshot does not appear until its alpha value is being animated, after 1 second.  The conclusion here is that 1) yes, the animation module overrides the defined, non-animated alpha value, and 2) the animation module currently remembers its last setting, at least for a given artwork, so for example if you had something fade to alpha 0, and start a new animation on the same artwork, any delay you put in will still be at alpha 0 for that duration.

My clunky solution, which works, is to do two animations in a row on the screenshot.  The first one is an alpha "transition" from 255 to 255 over a time of 1 ms (0 ms does not work).  The second is the intended fade.

So really the only thing missing here is a way to legitimately delay the appearance of a given artwork, so that videos won't be loaded or played until the delay is truly expired.

Edit: Actually, the ability to delay the loading of elements in general would be very welcome.  I use the Nevato theme (modded) for Mame, with the background set to display the flyer.  Over USB 2.0, those flyers take long enough to load that it has an impact on how fast I can navigate the menu.  It would be great if I could tell AttractMode to wait a moment before loading the background, so the load time doesn't clog everything.  As far as I know, however, all you can do currently is what is provided by the animation module, and things still get loaded in immediately even if it is used.
« Last Edit: June 22, 2017, 06:50:17 PM by Asterra »

Asterra

  • Full Member
  • ***
  • Posts: 44
    • View Profile
Re: Adding artwork: Forcing it to fade in? Or out?
« Reply #6 on: June 22, 2017, 07:21:13 PM »
Last problem I have here is that this process of having the screenshot fade out doesn't seem to be able to work 100% of the time, because ToNewSelection only covers every game that displays after the first one, and StartLayout only covers the first game that displays.  Since the script in a layout only executes once, there is no way to tell AttractMode to use StartLayout the first time and ToNewSelection every time thereafter.  (Or, perhaps more to the point, there is no "when" option that covers both cases.)