DirectX SDK

Step 5: Play an Effect

[Visual Basic]

The information in this topic pertains only to applications written in C++. See DirectInput Visual Basic Tutorials.

[C++]

The effect created in the previous step starts in response to the press of a button. In order to create an effect that is to be played in response to an explicit call, you need to go back to Step 4 and modify the dwTriggerButton member of the DIEFFECT structure, as follows:

diEffect.dwTriggerButton = DIEB_NOTRIGGER;
 

Now, suppose you want to make a chain saw that actually starts and keeps going. This is simply a matter of changing the dwDuration member as follows:

diEffect.dwDuration = INFINITE;
 

Starting the effect is very simple:

g_lpdiEffect->Start(1, 0);
 

The effect will keep running until you stop it:

g_lpdiEffect->Stop();
 

Note that you don't need to change the envelope you created in the previous step. The attack is played as the effect starts, but the fade value is ignored.

Next: Step 6: Change an Effect