Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
passing the context data pointer passed the actor

Passing the context data pointer passed the actor step

511,
strDefinition );

// Attempt to load the sound
m_pSoundManager->Create( &m_pSamples[i].pSound, m_pSamples[i].FileName );

}

2.Call to LoadActorFromX is passed a context pointer that will be passed to the callback function registered in step 1.

3.After the actor has loaded the animation data it will loop through each loaded animation set and call the callback function, passing it the context data pointer passed to the actor in step 2. We use this to pass a .cbd filename to the function (in our lab project).

CSoundCallback::HandleCallback

This function has a very simple job. It will be called by the callback handling function every time the callback key is triggered. It has to decide which sound to play from its play list (based on its mode of operation) and play that sound.

In our case the function is simple -- we just wish to play a sound. If the m_bRandom boolean variable is set to true then we generate a random index into the SampleItem array. If not, then we are in cycle mode and the m_nNextPlayIndex variable will hold the index of the next sound to play (0 initially). We use our index to access the SampleItem array and call the Play method of the CSound object that is stored there. Here is all of the code:

HRESULT CSoundCallback::HandleCallback( UINT Track, CActor * pActor ) {
ULONG PlayIndex;

}

Notice that after the sound has been played, the m_nNextPlayIndex variable is incremented and wrapped around to zero if it exceeds the maximum sample count.

That covers the code for the CSoundCallback object. This class also has AddRef, Release, and QueryInterface methods, but you should be very comfortable with these types of functions by now, so will not show or discuss their implementation again here.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Maurice Clarke

PageId: DOC9D78977