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

Author Topic: Fade Music and question for method  (Read 6516 times)

0 Members and 1 Guest are viewing this topic.

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Fade Music and question for method
« on: March 04, 2012, 12:26:02 PM »

Hi, i have create this simply script for fade in the music. This work ::beer


Code: WME Script
  1. Game.PlayMusicChannel(2,"path music");
  2.  
  3.  
  4. var volume ;
  5.   for (volume=volume; volume>1; volume=volume-1)
  6.                 {
  7.                 Game.SetMusicChannelVolume(2,volume);
  8.                 Game.Msg(volume);
  9.                 Sleep(100);
  10.                 }

i have a question for create a method for dont rewrite this code for any scene, how can done it?

i have try with this in the game.script
method MusicFade(Channel)
{
   var volume ;
   volume = Game.GetMusicChannelVolume(Channel);
   for (volume=volume; volume>1; volume=volume-1)
      {
      Game.SetMusicChannelVolume(Channel,volume);
      Game.Msg(volume);
      Sleep(100);
      }
}

and in the scene i have put code
Game.MusicFade(2);

but dont work  :'( 

any idea..?

p.s. game.msg is only for check..
« Last Edit: March 04, 2012, 12:33:08 PM by keybone »
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: Fade Music and question for method
« Reply #1 on: March 04, 2012, 07:35:09 PM »

I'd suggest you use a separate variable for your loop to the one for your volume so you don't corrupt them. You can still use 'volume' as your seed. Try:
for(var loop = volume; loop > -1; loop = loop -1)
  {
  Game.SetMusicChannelVolume(2, loop);
  Sleep(100);
  }

Hope that helps
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

keybone

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 112
    • View Profile
    • Lucine
Re: Fade Music and question for method
« Reply #2 on: March 04, 2012, 08:47:14 PM »

tk for info Kaz;)

i have work on the script and i have find finally  ::rock how use method for done fadeIn e FadeOut of the music.

first to all crate methods.inc

and put this code:

Code: WME Script
  1. method MusicFadeOut(Channel)
  2. {
  3.    var volume ;
  4.    volume = Game.GetMusicChannelVolume(Channel);
  5.    var loop;
  6.    Game.Msg(volume);
  7.    for (loop=volume; loop>1; loop=loop-1)
  8.                 {
  9.                 Game.SetMusicChannelVolume(Channel,loop);
  10.                 Game.Msg(loop);
  11.                 Sleep(100);
  12.                 }
  13. }
  14. //////////////////////////////
  15. //to increase the volume to the level that we want (VolumeMax)
  16. method MusicFadeIn(Channel, volumeMax)  //channel and volumeMax
  17. {
  18.    var volume ;
  19.    volume = Game.GetMusicChannelVolume(Channel);
  20.    var loop;
  21.    Game.Msg(volume);
  22.    for (loop=volume; loop<volumeMax; loop=loop+1)
  23.                 {
  24.                 Game.SetMusicChannelVolume(Channel,loop);
  25.                 Game.Msg(loop);
  26.                 Sleep(100);
  27.                 }
  28. }
  29.  

then in base.inc add in methods.inc

Code: WME Script
  1. #include "scripts\methods.inc"

for use the methods

FADEIN

Code: WME Script
  1. Game.PlayMusicChannel(2,"path muisc");
  2.  
  3. Game.MusicFadeIn(2,70);

in this way the volume increases to the maximum volume, in this case we decided that is 70.

FADE OUT

Code: WME Script
  1. Game.PlayMusicChannel(2,"path muisc");
  2. Game.MusicFadeIn(2);
  3.  

in this way diminish the volume gradually to 0.

of course remove Game.Msg. I am just to check if everything works.
I hope I can help someone. ::wave
« Last Edit: March 04, 2012, 08:54:54 PM by keybone »
Logged
Lucine Company http://www.lucine.it/
Tales of Lucine: The Realm of Hobdark http://www.lucine.it/TalesOfLucine
 

Page created in 0.051 seconds with 21 queries.