Assigning Audio length to a variable

Get help using Construct 2

Post » Wed Jul 10, 2013 4:56 am

Hi guys!
I am working on a small project and I need some help. The project has some sprites that play a sound when they are touched. The sound clip assigned to each sprite has a different length of time.
I'm trying to assign the length of the last audio clip played to a global variable called AUDIO_LEN (using the Audio.Duration expression).
The first time the sprite is touched, the value of AUDIO_LEN does not change. The second time the sprite is touched, the value of AUDIO_LEN is accurate.
The expectation is for AUDIO_LEN to get the right value the first time.

CAPX here.

Thank you very much for your help!!!
B
28
S
10
G
10
Posts: 97
Reputation: 6,584

Post » Wed Jul 10, 2013 6:19 am

You need to preload the sounds first, otherwise the duration can't be determined (until the next time, when it's been loaded already).
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Wed Jul 10, 2013 7:40 am

Thanks blackhornet! Preloading the audio solved the problem.
B
28
S
10
G
10
Posts: 97
Reputation: 6,584


Return to How do I....?

Who is online

Users browsing this forum: ASHKAR, brunopalermo and 26 guests