sounds and variables

Get help using Construct 2

Post » Sun Oct 13, 2013 12:32 pm

Hello friends, I was wondering how I'd go about making an object change its sound every time you touch it (cycling through 5 different sounds over and over.) I know I should probably use a variable to change the sound, just not sure how to implement it properly. Any help would be great, thanks!
ImageImage
B
36
S
8
Posts: 312
Reputation: 2,780

Post » Sun Oct 13, 2013 12:43 pm

Random sounds or in the same order?
OnTouch > Add 1 to variable
If variable = 1 > Play Sound 1
if variable = 2 > Play Sound 2
etc.
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Sun Oct 13, 2013 12:51 pm

Thanks Plinkie. Actually Im looking to do random sounds on one object and another object with sounds cycling in order. My problem really is finding the action under my object that plays the sound controlled by the variable. Im sure its something easy, maybe Im just being lazy haha..I'll keep plugging away at it.
ImageImage
B
36
S
8
Posts: 312
Reputation: 2,780

Post » Sun Oct 13, 2013 12:56 pm

Just link a sound up to a number. If variable is 1 then play sound 1 etc. easy! If you want to do a random sound it'll be something like OnTouch > variable = rand(min,max). This will set the variable to a random number and play the sound linked to it.
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Sun Oct 13, 2013 1:29 pm

Okay Plinkie I get the logic but cant find the command to check the variable, the "if variable =", how do i do that check then play a sound. Thanks a millionBilly Bleeks2013-10-13 13:30:09
ImageImage
B
36
S
8
Posts: 312
Reputation: 2,780

Post » Sun Oct 13, 2013 1:37 pm

I cant seem to compare the variable inside the object as an action
ImageImage
B
36
S
8
Posts: 312
Reputation: 2,780

Post » Sun Oct 13, 2013 1:41 pm

Add Event > "Object" > Compare Instance Variable
B
46
S
16
G
78
Posts: 2,168
Reputation: 46,353

Post » Sun Oct 13, 2013 1:46 pm

To play random sounds you can use the choose command. In these examples I'll asume you have 3 sounds.

On object touched - play sound: choose("sound1","sound2","sound3")

For the sounds in order give the object an instance variable sound

on object touched - object add 1 to variable sound.
(subevents)
-object compare instance variable = 4 - object set variable soundd to 1
(subevents)
-object compare instance variable = 1 - play sound: "sound1"
-object compare instance variable = 2 - play sound: "sound2"
-object compare instance variable = 3 - play sound: "sound3"


I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 13, 2013 10:29 pm

Amazing help and super quick responses, mucho love to you! Thanks
ImageImage
B
36
S
8
Posts: 312
Reputation: 2,780

Post » Mon Oct 14, 2013 8:21 am

how about when you go to other layout sound well change how to do that..?
B
12
S
1
Posts: 31
Reputation: 607

Next

Return to How do I....?

Who is online

Users browsing this forum: Darknessed and 43 guests