How can the iPhone be set to vibrate once?
For example, when a player loses a life or the game is over, the iPhone should vibrate.
From "iPhone Tutorial: Better way to check capabilities of iOS devices":
There are two seemingly similar functions that take a parameter kSystemSoundID_Vibrate
:
1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on the other hand, does nothing on unsupported devices. So if you are going to vibrate the device continuously, as an alert, common sense says, use function 2.
First, add the AudioToolbox framework AudioToolbox.framework
to your target in Build Phases.
Then, import this header file:
#import <AudioToolbox/AudioServices.h>