Different music?

Non-platform specific questions.

Different music?

Postby GuybrushThreepwood » Wed May 12, 2010 10:16 pm

Can i make a song play right after one finishes?
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Different music?

Postby Hblade » Thu May 13, 2010 1:31 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Different music?

Postby Camper1995 » Thu May 13, 2010 4:13 pm

Wow cool idea dude! Thanks! This is so helpfull! ;)
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron