Search code examples
ioscocos2d-iphoneaccessibilityvoiceover

Can I support VoiceOver in my Cocos2D-iPhone Game?


I'm making a game where a player reacts to sounds via motion - seeing as the visual element isn't needed to play it, and many play with their eyes closed, it seems a shame to not be fully VoiceOver compatible. I'm currently using Cocos2D-iPhone and CocosDenshion for audio, and am now starting to think about how I'll be building my menu system to choose levels and configure controls.

Is it reasonably easy to support VoiceOver in Cocos2D's menu system, or should I look in to trying to create my menus in UIKit which I have no experience using?


Solution

  • I don't know if Cocos' menu system supports VoiceOver, but if it doesn't, you could probably add the functionality you're looking for yourself without having to delve into a lot of UIKit work. All you need to do is create a UIView subclass which gets added to your main window when your app starts up. Then use the UIAccessibilityContainer protocol and UIAccessibilityPostNotification calls to allow users to interact with your game via VoiceOver.

    The UIAccessibilityContainer protocol lets you inform VoiceOver what interface elements are currently on the screen, their labels, their traits, etc. VoiceOver then uses this information to let users swipe between elements and get feedback on them.

    When your game changes state, you can change what that protocol sends back and then issue a

    UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil)

    ...to inform VoiceOver that the screen layout has changed. And to just speak something via VoiceOver, say when your game state has changed, you can send a different notification to speak some text:

    UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Achievement unlocked!");