Can I support VoiceOver in my Cocos2D-iPhone Game?

自闭症网瘾萝莉.ら 提交于 2020-01-03 17:12:30

问题


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?


回答1:


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!");




回答2:


No need to go with UIKit framework you can go with the cocos2d native methods and class to implement this.

For sound option we have SimpleAudioEngine Which can be used. you can distinguish between sound using its ID which is of type ALuint.

ALuint soundEffectID;

//to start
soundEffectID=[[SimpleAudioEngine sharedEngine] playEffect:@"my sound"];
//to stop
[[SimpleAudioEngine sharedEngine] stopEffect:soundEffectID];

You have to mange these effect and I think your problem will be solved.



来源:https://stackoverflow.com/questions/9899285/can-i-support-voiceover-in-my-cocos2d-iphone-game

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!