how to play sound in first click and stop in the next click?

Discussion and feedback on Construct 2

Post » Sun Nov 08, 2015 9:43 am

how to play sound in first click and stop in the next click?

my code for play file but how can i stop the music from the same button?

Image
B
13
S
2
Posts: 95
Reputation: 861

Post » Sun Nov 08, 2015 4:43 pm

Hi, on event 3 you could try:

On Left Button Clicked on AbdullahPic
(subevent) Audio: Not Tag "ddd" is playing : Play bass tag "ddd" looping
(subevent) else : Stop tag "ddd"
B
21
S
9
G
4
Posts: 473
Reputation: 4,285

Post » Mon Nov 09, 2015 1:13 am

Take your button sprite and create boolean variable. Name it something like "Is_Playing". Now events:

Main Event
On BUTTON clicked
Sub-Events
- Is_Playing : Stop, toggle boolean "Is_Playing"
- Else : Play, toggle boolean "Is_Playing"
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
92
S
30
G
22
Posts: 1,987
Reputation: 20,178


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests