![]() |
|
Small problem. |
julian_boolean
Member #8,201
January 2007
|
I'm using the code for the LS button (http://www.loomsoft.net/util_lsbutton.shtml) and was just trying to get rid of one of the functions that was there originally. So far it seems to work fine except for the fact that it doesn't play the sound effects.
|
CGamesPlay
Member #2,559
July 2002
![]() |
Shouldn't you call the sounds function somewhere? -- Ryan Patterson - <http://cgamesplay.com/> |
Taiko Keiji
Member #8,307
February 2007
![]() |
The problem I noticed is that when you send a value to sound_status it's either PLAY_SOUND_ON || PLAY_SOUND_DOWN when you check the sound_status you should be checking for these instead of int button::is_clicked(void) } else if(mouse_b & 1 && mouse_status != NOT_ON_FOCUS) else if(!(mouse_b & 1) && mouse_status == MOUSE_STATUS_DOWN) return TRUE; else if(!(mouse_b & 1)) else return FALSE void button::draw(BITMAP *bitmap_buffer) if(draw_frame == DRAW_FRAME_ON) if(draw_frame == DRAW_FRAME_OFF) void button::sounds(void) if(sound_status == PLAY_SOUND_ON) if(sound_status == PLAY_SOUND_OFF) Hope this helps, If i'm not even close i'm sorry. Life could be better, machines could program themselves. Taiko Keiji- |
CGamesPlay
Member #2,559
July 2002
![]() |
All you did was change this line, correct? -- Ryan Patterson - <http://cgamesplay.com/> |
Taiko Keiji
Member #8,307
February 2007
![]() |
which line? Life could be better, machines could program themselves. Taiko Keiji- |
julian_boolean
Member #8,201
January 2007
|
Nada :/ And I am calling the function in the game state I'm using it in, it doesnt really make a difference and I figure I shouldn't have to anyway. |
Taiko Keiji
Member #8,307
February 2007
![]() |
Sorry, I tried. Life could be better, machines could program themselves. Taiko Keiji- |
julian_boolean
Member #8,201
January 2007
|
Thanks though Edit: It used to say: else if(!(mouse_b & 1)) { mouse_status = NOT_ON_FOCUS; draw_frame = DRAW_FRAME_OFF; sound_status = PLAY_SOUND_OFF; } Dunno if it made a difference though. Edit again! Oops typo, it's suppose to say PLAY_SOUND not SOUND_STATUS (still not working though.) |
CGamesPlay
Member #2,559
July 2002
![]() |
The sounds function needs to be called whenever the value of sound_status changes. That means that when you set sound_status = PLAY_SOUND_OFF, you need to call sounds(); right afterwards. -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Why is it any different though. Then logically I should have to call the draw function right after the value of draw_frame changes, but I don't.. Edit: That doesn't seem to work either. |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: Then logically I should have to call the draw function right after the value of draw_frame changes, but I don't.. If you look at the sounds function, you will see that it starts and stops sounds, whereas the draw function actually redraws frames. You don't need to "redraw" sounds. Clearly, the sounds function is meant to be called when the sound needs to change. If it doesn't work, are you sure that the sounds are loaded? -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Hmm.. Well the sounds are being loaded just fine. Before I made this change it worked perfectly.. I tried taking out the stop_sample in each of the if statements and it worked, sorta. |
CGamesPlay
Member #2,559
July 2002
![]() |
SO, problem solved? -- Ryan Patterson - <http://cgamesplay.com/> |
julian_boolean
Member #8,201
January 2007
|
Yup, except for the fact that it crashes when I press the button and just before I do it sounds as if it plays the sound file about 100 times. Don't I need to use stop_sample or else when I go to play a different sound (when the status changes) it'll play the previous one as well? |
Steve Terry
Member #1,989
March 2002
![]() |
You need something like this: if(play_this_sound) { play_sample(this_sound); play_this_sound = false; } That way it only calls play_sample once ___________________________________ |
|