Page 1 of 1

Different music?

PostPosted: Wed May 12, 2010 10:16 pm
by GuybrushThreepwood
Can i make a song play right after one finishes?

Re: Different music?

PostPosted: Thu May 13, 2010 1:31 pm
by Hblade
Yeah but that's a bit advanced :D But I'll explain :3

First, you have to find out exactly how long the audio file is. Then you have to figure what your frame rate is, (Config - Game Options)
Exam 1.JPG


Now make a variable to be used as a timer, because the timer function would be innacurate since I dont know how to correctly use it :P Anyways, make a variable called timer. Now, as you see in the screenshot, it's 30, right? every 30 frames is 1 second, so in the draw actor of the view, use this code:
Code: Select all
timer++;


So now, take however many seconds are in the song, and multiply it by the frame rate. For example, a 2:45 second audio file would be 4950 frames if your FPS is 30. If it's anything higher you have to multiply the secodns by the frame rate you have.

Now use an if statement to change the song :D Do the same thing for the next song :)

Before you continue though, make another variable to determan which song your on. Name it song
Code: Select all
if (timer == 4950 && song == 0)
{
    play second song :D
    timer = 0;
    song = 1;
}
if (timer == second song length && song == 1)
{
    play first song :D
    timer = 0;
    song = 0;
}


Hope this helped :D If it's too confusing I could break it down more :D

Re: Different music?

PostPosted: Thu May 13, 2010 4:13 pm
by Camper1995
Wow cool idea dude! Thanks! This is so helpfull! ;)