Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Dark gdk sound problem

Author
Message
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 9th Dec 2008 17:49
hi, i was trying to add sounds to my click button events, butt its wierd
its like its like you click realy fast that you get a normal sound else(if u hold down the mouse its like it starts and keep on starting.
i useed this code


Game.Love
Duncan
16
Years of Service
User Offline
Joined: 7th Jun 2008
Location:
Posted: 9th Dec 2008 17:54
Just a stab, but can you associate the sound with a mouse "onButtonDown" event insteand on onClick
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Dec 2008 18:01
try:
if (!dbsoundPlaying(9)) dbPlaySound(9);
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Dec 2008 18:17
Keep in mind that a mouse click doesn't say that the mouse was clicked once. It means that the mouse button is being pressed. If you're checking it in a loop it will always returned a clicked status while you're holding down the mouse button.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 9th Dec 2008 18:19
got it working:


but now i have a new problem. if u hold it just keeps on beeping.
how do you made the if you hold the it only beeps once at start=?

Game.Love
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Dec 2008 18:34
Quote: "how do you made the if you hold the it only beeps once at start=?"


See my answer above. It's rather involved trying to keep track of when a button is just clicked and just released and how you handle it. The manner in which you handle it largely depends on your overall code. You might think about going OOP on the mouse and have a look at my Mouse class posted elsewhere in this forum.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mighty Batsonator
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Atmosoft Ltd. World Headquarters
Posted: 9th Dec 2008 18:39
You've got the framework in place to play the sound when dbMouseClick() returns 1. What if you had a bool called "hasBeenPlayed", that you set to true after you play the sound. Then you only play the sound again if its false, which doesn't happen until dbMouseClick() returns 0 (i.e. The mouse is no longer pressed).

-- Coding your worst nightmare --
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 10th Dec 2008 14:06
1 more question!

how do you disable the sound when it was clicked(when the exit button is clicked a warning woud show up, but you could press the button no more, and one morething i can make the sound event "onButtonDown" becous i have if u are at that position whit the mouse it just can beeep.else not:!

pls help-!

Game.Love
Mighty Batsonator
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Atmosoft Ltd. World Headquarters
Posted: 10th Dec 2008 14:44
Sounds like another job for a bool to me...

if(button has been clicked and sound has been played)
{
cannot click button again = true
}

-- Coding your worst nightmare --

Login to post a reply

Server time is: 2024-09-30 11:36:16
Your offset time is: 2024-09-30 11:36:16