Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: subspark on Sat 13/11/2010 10:45:32

Title: Some assistance with fading timers
Post by: subspark on Sat 13/11/2010 10:45:32
Hey there folks,
I'm having a bit of difficulty fading things in at the right time.

Put basically into a timeframe of seconds:

0:00 TitleParent fades in
0:20 TitleChild fades in
1:20 TitleChild fades out
1:50 TitleChild fades back in with new .graphic and .x properties.
2:50 TitleChild fades out
2:70 TitleParent fades out
2:80 ChangeRoom

I hope that makes enough sense. :P

Thanks in advance.
Sparky.

Title: Re: Help with fading timers.
Post by: Khris on Sat 13/11/2010 11:00:38
What are you fading in/out? Objects?
How long does it take them to fade in/out?

The main question is, do you even need timers for this? Why not use Wait()?
Or is the player supposed to be able to something while this runs?
Title: Re: Help with fading timers.
Post by: subspark on Sat 13/11/2010 11:05:12
QuoteWhat are you fading in/out? Objects?
QuoteHow long does it take them to fade in/out?
I'm fading objects and the correct times for all the fading is above in second:millisecond format.

1:20 is one and a third seconds. 3x 20 = 60  (1 second)

Quotedo you even need timers for this? Why not use Wait()?
I'm not using anything at the moment. I tried wait but to no avail.

Quoteis the player supposed to be able to something while this runs?
This is a blocking function but I will need to create a non-blocking one later as well. I'll post here again at that stage.

Cheers,
Sparky.
Title: Re: [Still Unresolved] Help with fading timers.
Post by: subspark on Sat 13/11/2010 14:35:21
Any ideas anyone? I'm still kind of lost in my own code here. ^^

Cheers,
Sparky.

EDIT: I've partly got waits working in int variable sequences but mostly shitty result.  ::)
Title: Re: [Still Unresolved] Some assistance with fading timers
Post by: monkey0506 on Sat 13/11/2010 14:57:43
Take it easy Paul..it's only been three hours. := Lemme see here..brb!
Title: Re: [Still Unresolved] Some assistance with fading timers
Post by: subspark on Sat 13/11/2010 14:58:47
Ahh! No probs Mikey.  8)
Thanks.
Title: Re: [Still Unresolved] Some assistance with fading timers
Post by: Khris on Sat 13/11/2010 15:07:58
By how long I meant "how long does the fading itself take"?

Quote0:20 TitleChild fades in
1:20 TitleChild fades out

When is TitleChild faded in completely? At 0:40? At 1:00?

Not sure how useful it is to state a time as 2:70 seconds when you said earlier that 1:20 is 1.33 seconds.
So 2:70 is 3:10? Or did you mean 2:42?
Nevermind me also being a smartass, what you want to do is state the transparency as a function of the time.

At default speed, a gameloop is 1/40 seconds, so the timetable looks roughly like this (way to fast I'd say btw):

0 TitleParent fades in
13 TitleChild fades in
53 TitleChild fades out
60 TitleChild fades back in with new .graphic and .x properties.
100 TitleChild fades out
110 TitleParent fades out
115 ChangeRoom

Assuming that TitleChild fades in from 0:20 to 1:40, that's 13-40.

int timer;

function room_RepExec() {

  if (timer < 13) {}
  else if (timer <= 40) oTitleChild.Transparency = (timer*(-100))/27+149;
  else if (timer < 53) {}
  else if (timer <= 80) oTitleChild.Transparency = (timer*100)/27-196;
  else if (timer == 81) {
    oTitleChild.Graphic = ?;
    oTitleChild.X = ?;
  }
  ...

  timer ++;
}
Title: Re: [Still Unresolved] Some assistance with fading timers
Post by: subspark on Sat 13/11/2010 15:17:06
Crikey. Thanks, Khris.
I was caught between multiple solutions. DKH was helping me on msn (which was being an absolute dog and disconnecting every few moments), spacepaw caught me on Skype because I happen to be on there while I posted here and good ol' monkey was kind enough to give it a whirl. Thanks to all of youz guys. Means a lot.

Khris: Nah, your not a smartass, I kind of screwed up the information a bit. My brain's only firing on one cylinder tonight which is probably why so many folks got my cry for help.

Thanks again.
Sparky.
Title: Re: Some assistance with fading timers
Post by: edmundito on Sat 13/11/2010 18:00:06
If you were doing this whole thing blocking you could really easily do it with the Tween module:


oTitleChild.Transparency = 100;
oTitleParent.Transparency = 100;

// ...

oTitleParent.TweenTransparency(0.5, 0, eEaseOutTween, eNoBlockTween);
WaitSeconds(20.0);
oTitleChild.TweenTransparency(0.5, 0, eEaseOutTween, eNoBlockTween);
WaitSeconds(60.0);
oTitleChild.TweenTransparency(0.5, 100, eEaseOutTween, eNoBlockTween);
WaitSeconds(30.0);
oTitleChild.Graphic  = ...;
oTitleChild.x = ...;
oTitleChild.TweenTransparency(0.5, 0, eEaseOutTween, eNoBlockTween);
WaitSeconds(60.0);
oTitleChild.TweenTransparency(0.5, 100, eEaseOutTween, eNoBlockTween);
WaitSeconds(20.0);
oTitleParent.TweenTransparency(0.5, 100, eEaseOutTween, eNoBlockTwen);
WaitSeconds(10.0);

player.ChangeRoom(...);


However, non-blocking is always a little trickier. :( It's actually one of those problems that I'd like to solve one day and make it available in the module...  :)
Title: Re: Some assistance with fading timers
Post by: subspark on Sun 14/11/2010 08:48:11
Thanks, Edmundito.
I overlooked your module. Sure has come in handy in more than one way.
Hopefully we can get it to be non-blocking if you don't get to that first.

Cheers,
Sparky.
Title: Re: Some assistance with fading timers
Post by: edmundito on Sun 14/11/2010 21:00:01
Hmm... I do have a pretty good idea of how I would do it, actually. Looks like I may cook up another module... if only I was paid to do this haha. I guess it's kind of fun.
Title: Re: Some assistance with fading timers
Post by: subspark on Sun 14/11/2010 21:43:39
Your on fire man! Keep the rolling the dev... Us too, if your clever enough! Hey I would pay you, but I just kind of spent all my money on a couple of strippers and some coke! Er... Did I just make that excuse out loud!? :D

Thanks for the great tools though, Edmundito. You work rocks hard!
Sparky.