Original Post
I have some problem about playing the sound of button. I want to create some OnMouseOver event to my mouse button, because directX don’t support this so I do it in this way, when the mouse cursor point to position of the button on the screen, the button sound will play(like the code below). But I have some problem about this, when the mouse over the button the sound will keep continuing playing non stop, I think it’s because I play the sound inside the onframerender, so everytime the frame render then same sound file will play agains and agains. Anyone could help me solve this problem please.
Quote:
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime ) { if( cursorPoint.x >= CX_SCREEN*3/4 && cursorPoint.x <= CX_SCREEN*19/20 ) { if( cursorPoint.y >= CY_SCREEN/2 && cursorPoint.y < CY_SCREEN*5/ 8) { onButtonSound(onStartButton); } } }
Quote:
void onButtonSound(int button) { TCHAR strFileName1[MAX_PATH] = TEXT("start.wav"); g_pButtonSoundManager = new CSoundManager(); g_pButtonSoundManager->Initialize( hwnd,DSSCL_PRIORITY); if (button == onStartButton) { g_pButtonSoundManager->Create( &g_pButtonSound, strFileName1, 0, GUID_NULL,1 ); break; } g_pButtonSound->Play( 0, 0); g_pButtonSound->Reset(); g_pButtonSound = NULL; g_pButtonSoundManager = NULL; }