How do I make duplicate buttons independent?

Get help using Construct 2

Post » Sun Aug 19, 2012 4:16 pm

I've two buttons, one duplicated from the other.

On the first button, I want to play a sound file that says "yes" and the other button to play a sound that says "no".

I thought it would be simple but am having difficulty trying to do this (newbie I suppose.)

Is it possible to assign different sound files to duplicate buttons, ie a soundboard?

Thanks!
Bob
B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sun Aug 19, 2012 4:21 pm

What I like to do is create an instance variable called ID. And then assign each instance a different value: 1,2,3...

That way when you do the events you can do:
+ On button clicked
If button instance variable ID = 1 - play sound1
If button instance variable ID = 2 - play sound2
etc.
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Sun Aug 19, 2012 6:34 pm

Ok cool! I was able to use the variable instance to specify which sound to play.

I have two mouse onclick entries each checking the id to play that specific audio.

According to your scenario, you have one entry for mouse click. I assumed this would be the optimal way.

Do you have a sample of how this could be done?

Thanks again!

Bob




B
31
S
6
G
4
Posts: 160
Reputation: 5,998

Post » Sun Aug 19, 2012 7:31 pm

You use subevents basically, like this:



Is that clearer?
B
63
S
23
G
17
Posts: 254
Reputation: 14,342

Post » Sun Aug 19, 2012 7:52 pm

Ah yes, thank you! This makes perfect sense now.
B
31
S
6
G
4
Posts: 160
Reputation: 5,998


Return to How do I....?

Who is online

Users browsing this forum: mallorcaredes, Matthew de and 2 guests