Skip to content

Latest commit

 

History

History
41 lines (26 loc) · 1.39 KB

sound_effects.md

File metadata and controls

41 lines (26 loc) · 1.39 KB

Sound Effects and Impact Feedback

SwiftFortuneWheel can play sounds when the edge or the center of a slice moves during the rotation. Optionally, it’s possible to turn on the haptic feedback while playing sound.

Edge Collision Sound Effect Example

@IBOutlet weak var fortuneWheel: SwiftFortuneWheel!
// after SwiftFortuneWheel init and configuration…

// add Click.mp3 to your project, create AudioFile, and set to edgeCollisionSound
fortuneWheel.edgeCollisionSound = AudioFile(filename: "Click", extensionName: "mp3")

// optionally, turn on the haptic feedback for each impact
fortuneWheel.impactFeedbackOn = true

// turn on the edge collision detection
fortuneWheel.edgeCollisionDetectionOn = true

Center Collision Sound Effect Example

@IBOutlet weak var fortuneWheel: SwiftFortuneWheel!
// after SwiftFortuneWheel init and configuration…

// add Click.mp3 to your project, create AudioFile, and set to centerCollisionSound
fortuneWheel.centerCollisionSound = AudioFile(filename: "Click", extensionName: "mp3")

// optionally, turn on the haptic feedback for each impact
fortuneWheel.impactFeedbackOn = true

// turn on the center collision detection
fortuneWheel.centerCollisionDetectionOn = true

impactFeedbackOn is only available on iOS 10 and above, not available on other platforms

For more information, see example projects