Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
| Note: If a device is unacquired (as would happen when another application gained focus), all effects are automatically unloaded. Effects should be downloaded again when the device is reacquired, especially triggered effects for which the Start method will never be called.
#### Start the Effect Once the effect is downloaded, it can be played. Triggered effects are started whenever the specified button is pressed, but non-triggered effects must be explicitly told to begin playing. This is accomplished by calling the Start method of the IDirectInputEffect interface. Note that the input device must be acquired at the exclusive cooperative level before the Start method will succeed. The Start method is defined as:
    function Start(

    dwIterations: DWORD;                 // number of times to repeat the effect

    dwFlags: DWORD                       // playback flags

    ) : HResult;                         // returns a DirectX error code
The dwIterations parameter indicates how many times to play the effect. This parameter can be set to a positive integer value or to INFINITE, indicating it will continue playing until explicitly stopped. Of course, for effects that have a defined duration of INFINITE, the dwIterations parameter is effectively useless, and some devices do not even support multiple iterations. The dwFlags parameter indicates how the effect should be played on the device. By default, an effect will be mixed with other effects currently playing on the device when it is started. Setting this flag to DIES_SOLO will stop all other currently playing effects before playing the new effect. The DIES_NODOWNLOAD flag can also be used to indicate that the effect should not automatically be downloaded. This parameter can be set to zero or any combination of these two flags.
| Note: If the effect is already playing when Start is called, it will stop and be restarted from the beginning.
#### Stop the Effect Effects with a finite duration or those associated with a button will automatically stop when the duration has been reached or the button is released. However, some effects, such as those explicitly started with an infinite duration, will continue to play until the device is unacquired. Sometimes, it may be necessary to stop an effect, and this is where the Stop method of the IDirectInputEffect interface comes in. It is defined as:
    function Stop : HResult;                // returns a DirectX error code
#### Case Study Creating force feedback effects, while somewhat confusing, isn’t quite as complicated as other DirectX subsystems. The following listing is a case study example which demonstrates how to create each type of effect. While not particularly robust, this example should serve to demonstrate how the above steps are followed for each effect type.
Previous | Table of Contents | Next

Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.