Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Pages: [1] 2  All

Author Topic: FadeOut and FadeIn  (Read 15555 times)

0 Members and 1 Guest are viewing this topic.

Daniel

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
  • I'm *not* a llama!
    • View Profile
FadeOut and FadeIn
« on: April 19, 2004, 01:01:29 PM »

Hi everybody,

I want to use the FadeOut and FadeIn methods but I'm not sure where to place these calls. I want to fade out the current scene the moment the user clicks the "Options" button, then open the "Main Menu" window (that covers the entire screen) in system exclusive mode, and only then fade in with the "Main Menu" window already in place.
I tried to place the FadeOut and FadeIn calls in the most logical places but I get weird results. The FadeOut works fine but the FadeIn doesn't work at all. The "Main Menu" window just appears without fading in. In addition, the FadeOut (that worked the first time) stops working as I go back and forth between the window and the scene, they just disappear and appear without fading out and in, and even the FadeOut that worked the first time stops working.

Does anybody know what am I doing wrong?
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: FadeOut and FadeIn
« Reply #1 on: April 19, 2004, 03:42:24 PM »

Hi Daniel,

I want to use the FadeOut and FadeIn methods but I'm not sure where to place these calls. I want to fade out the current scene the moment the user clicks the "Options" button, then open the "Main Menu" window (that covers the entire screen) in system exclusive mode, and only then fade in with the "Main Menu" window already in place.

With some help of Mnemonic, this part works fine for me. I guess you made the same mistake as I did and used Scene.FadeIn instead of Game.FadeIn.

I tried it this way in the game.script:

Code: [Select]
    // load and display the main menu window
    Game.FadeOut(1000, 0, 0, 0, 255);
    WinCaption.Visible = false;
    var WinMainMenu = Game.LoadWindow("interface\system\mainmenu.window");
    WinMainMenu.Center();
    Game.FadeIn(1000, 0, 0, 0, 255);
    WinMainMenu.GoSystemExclusive();
    [...]

It doesn't work for me the other way though (closing the Main Menu with FadeOut), since it seems you can't "FadeOut" the game (with opened Main Menu) while in exclusive mode, so the Main Menu window can only be closed to go back to game. Mnemonic is going to check this later...  ;)

Jerrot.
Logged
Mooh!

Daniel

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
  • I'm *not* a llama!
    • View Profile
Re: FadeOut and FadeIn
« Reply #2 on: April 19, 2004, 04:27:09 PM »

Thanks,

Well, The FadeIn works fine now, the reason it wasn't working before is because I seem to be an idiot... :-[

Anyway, the FadeOut still works only once (with the same code you posted). From the second time and on, the behavior is as follows: it goes black immediately, it then delays for the requested 1000msec with totally black screen, and only then the FadeIn of the window kicks in. Weird...

About the Fade methods not working in system exclusive mode, is there a real reason to this or is it just something that needs to be fixed?
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: FadeOut and FadeIn
« Reply #3 on: April 19, 2004, 04:46:43 PM »

Well, The FadeIn works fine now, the reason it wasn't working before is because I seem to be an idiot... :-[

Surely that's not the reason. ;)

Anyway, the FadeOut still works only once (with the same code you posted). From the second time and on, the behavior is as follows: it goes black immediately, it then delays for the requested 1000msec with totally black screen, and only then the FadeIn of the window kicks in. Weird...

Hmm, strange. After the part I quoted I only unloaded the window and made another FadeIn() and it worked fine, even multiple times. Maybe you could post us your whole event where you handle the Main Menu call ? And did you add anything to the window script (on "close"...) ?`

About the Fade methods not working in system exclusive mode, is there a real reason to this or is it just something that needs to be fixed?

Mnemonic told me to check it out, he thought it should work. Maybe I just made something wrong.
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #4 on: April 19, 2004, 05:58:17 PM »

Ok, here I am with a solution (hopefully :))

First the code to display the main menu:

[code]
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #5 on: April 19, 2004, 06:06:27 PM »

BUT! As I noticed now, I used GoExclusive instead of GoSystemExclusive. Because the GoSystemExclusive freezes the timer, making the fading unusable :(
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Daniel

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
  • I'm *not* a llama!
    • View Profile
Re: FadeOut and FadeIn
« Reply #6 on: April 19, 2004, 09:35:11 PM »

Well, now it's a lot better. The consecutive fade out problem is gone and both fade out and fade in work a lot better.

There are two issues remaining though:

1. What are the implications of the main menu window as well as all other windows (save, load, options, etc.) not working in system exclusive mode but only in exclusive mode? Does the fact that the game is not really paused when these windows are operated have any meaning at all? If so, do I have to give up the fading between the various windows?

2. The fading-in that is caused by the FadeIn call at the top of the window's script seems a lot more "sudden" than all the other fades, although it has exactly the same parameter as all the others. What could be the reason? Maybe a delay during window loading or something?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #7 on: April 19, 2004, 10:44:03 PM »

1. What are the implications of the main menu window as well as all other windows (save, load, options, etc.) not working in system exclusive mode but only in exclusive mode? Does the fact that the game is not really paused when these windows are operated have any meaning at all? If so, do I have to give up the fading between the various windows?

Well, if the window runs in system exclusive mode, it freezes all the other scripts. In a regular exclusive mode all the scripts keep running, i.e. something can happen while the player is not looking.
Anyway, I'll add some Game.FadeOut2 and Game.FadeIn2 methods which will be unfreezable.


2. The fading-in that is caused by the FadeIn call at the top of the window's script seems a lot more "sudden" than all the other fades, although it has exactly the same parameter as all the others. What could be the reason? Maybe a delay during window loading or something?

I haven't noticed that in my testing application...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Daniel

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 124
  • I'm *not* a llama!
    • View Profile
Re: FadeOut and FadeIn
« Reply #8 on: April 19, 2004, 11:21:28 PM »

Anyway, I'll add some Game.FadeOut2 and Game.FadeIn2 methods which will be unfreezable.

Is it necessary to have both FadeOut & FadeIn and also FadeOut2 & FadeIn2?

I haven't noticed that in my testing application...

Maybe I'm noticing this a bit more cause I'm using the default duration of 500msec. With this setting, the FadeIn at the top of the window's script is barely noticeable and the window just seems to appear almost immediately. The FadeIn after the Game.UnloadObject(WinMainMenu), however, is clearly noticeable with the same default duration of 500msec.

Anyway, this is a minor issue so don't feel obligated to check it right now, if you have a lot more burning issues to deal with. You can leave it for some other time when you find yourself bored with nothing else to do (which if you're anything like me, this means never ;))
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #9 on: April 20, 2004, 07:16:04 AM »

Is it necessary to have both FadeOut & FadeIn and also FadeOut2 & FadeIn2?

Yes, I think it is. While FadeOut and FadeIn are based on WME's internal timer, FadeOut2 and FadeIn2 will be based on Windows system timer. It means the first two will be saved together with savegames, while the second two won't. Both options are necessary because (in theory) you can have very long fades which need to be saved in progress (I know it's unlikely in case of fading the entire screen, but one never knows :))
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re: FadeOut and FadeIn
« Reply #10 on: April 20, 2004, 03:05:10 PM »

Yes, I think it is. While FadeOut and FadeIn are based on WME's internal timer, FadeOut2 and FadeIn2 will be based on Windows system timer. It means the first two will be saved together with savegames, while the second two won't. Both options are necessary because (in theory) you can have very long fades which need to be saved in progress (I know it's unlikely in case of fading the entire screen, but one never knows :))

Hehe, thinking about day/night cycles don't you? :P . Anyway, I don't like the "numbers" way, it can lead to errors while coding and you can forget what does what... Now it's only with Fades, but who knows, if it continues this way in the future, we'll might end up with a messy script system, and I don't want that, in fact I like WME scripting because every method name is very descriptive and logic. So why not adding a new parameter to the Fade* method for that feature, or giving it a more descriptive (but longer...) name like FadeInAsync or something if a new method is really necessary?
Logged

Click here to sign my sig!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #11 on: April 20, 2004, 03:45:52 PM »

Quote
Hehe, thinking about day/night cycles don't you?

Yes :) But as I said, it's unlikely someone's gonna use the Game.Fade* methods for it.


Quote
Anyway, I don't like the "numbers" way, it can lead to errors while coding and you can forget what does what... Now it's only with Fades, but who knows, if it continues this way in the future, we'll might end up with a messy script system, and I don't want that, in fact I like WME scripting because every method name is very descriptive and logic. So why not adding a new parameter to the Fade* method for that feature, or giving it a more descriptive (but longer...) name like FadeInAsync or something if a new method is really necessary?

Ok, you're not the only one who doesn't like it (hi Jerrot! ;)) Unfortunately adding a new parameter IMHO isn't feasible, since the fading methods already have a handful of optional parameters and if I added an extra one, you'd have to fill in all the others when using this new one.
Fade*Async also isn't possible, because these methods already exist (fading without blocking the script execution).
Ok, other ideas for names while keepng the names reasonably short? :)
There's another similar problem. I added the multi-channel music support, so currently there are two variations for each music function, such as PlayMusic / PlayMusic2, while the *Music2 functions take a channel number as the first parameter. Now, how to name all the secondary music functions? Jerrot suggested PlayMusicMC (for multichannel) but it's not exactly transparent either..
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re: FadeOut and FadeIn
« Reply #12 on: April 20, 2004, 04:08:26 PM »

Why not *MusicChannel? Maybe it doesn't look that good alone, but if it takes the channel number as first parameter, it wold be something like:

Code: [Select]
Game.StopMusicChannel(3);

Very straightforward and clear when it comes to coding IMHO ... Or maybe an optional parameter: if it's empty, then it works as the old method, and if there's some number, it uses that channel. It's not like with the fades methods because for PlayMusic there are currently only 2 parameters, and I think than a third optional one will not be that annoying. And moreover, for the rest of music functions, there's no parameter at all right now... (except for SetMusicPosition)

And about fades... you're right, there's async taken, I didn't know, so... maybe Fade*Global or something like that? Something short that shows that the process is independent from the rest of the main game loop... Fade*Daemon? But it's not exactly that... I'm out of ideas right now, but if something worthy comes to my mind, I'll post it.
« Last Edit: April 20, 2004, 04:11:40 PM by McCoy »
Logged

Click here to sign my sig!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: FadeOut and FadeIn
« Reply #13 on: April 20, 2004, 04:52:39 PM »

How about Fade*Unfreezable? Those methods will be rarely used anyway, so IMHO it doesn't really matter too much.

As for the music, yeah, thanks, that might work. Although GetMusicPositionChannel is a bit too long. I'm against adding an extra parameter to the existing methods, because in my opinion having the channel as a first parameter is much more consistent and transparent.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

McCoy

  • The cocido eater
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 365
  • Spurrrrrrring
    • View Profile
    • Spur Games
Re: FadeOut and FadeIn
« Reply #14 on: April 20, 2004, 05:21:31 PM »

Well, if someone is going to use a method a lot, and the name is long, he/she can always make some kind of "alias" trough scripting... It's a work-around, I know :-\... But it's that, or numbers, and IMHO the first option is better (just my taste).

And I think Fade*Unfreezable is OK, you're right, they're not going to be much-used methods so something descriptive is OK.
Logged

Click here to sign my sig!
Pages: [1] 2  All
 

Page created in 0.054 seconds with 20 queries.