[英]Cocos2d-iphone - Sphero Integration
I'm trying to connect a Sphero to a Cocos2d game I'm building. 我正在尝试将Sphero连接到我正在构建的Cocos2d游戏中。 Sphero has some good documentation and examples, and I can run the sample code.
Sphero有一些很好的文档和示例,我可以运行示例代码。 I started with a cocos2d project and added the Sphero frameworks.
我从一个cocos2d项目开始,并添加了Sphero框架。 I am not able to get a basic command to the ball.
我无法得到球的基本命令。 I believe the issue is in this function:
我相信问题在于这个功能:
-(void)setupRobotConnection
{
/*Try to connect to the robot*/
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRobotOnline) name:RKDeviceConnectionOnlineNotification object:nil];
if ([[RKRobotProvider sharedRobotProvider] isRobotUnderControl])
[[RKRobotProvider sharedRobotProvider] openRobotConnection];
}
(The rest of the code is at the link) I believe that it has something to do with the NSNotificationCenter. (其余代码在链接处)我相信它与NSNotificationCenter有关。 I am calling this code from a CCLayerColor, rather than a UIViewController like the demo does.
我从CCLayerColor调用此代码,而不是像演示那样调用UIViewController。 I get this error:
我收到此错误:
2012-08-25 01:54:19.738 bgmmo[1414:2d07] ERROR - opening session failed as protocol com.orbotix.robotprotocol is not declared in Info.plist
(This was answered in the Sphero IOS Forum ) (这在Sphero IOS论坛中得到了回答)
You need to add the external accessory protocol string to your Info.plist.
您需要将外部附件协议字符串添加到Info.plist中。 Edit the Info.plist for you application target and add a entry for key "Supported external accessory protocols" which will create an array enter.
编辑您的应用程序目标的Info.plist,并为关键的“支持的外部附件协议”添加一个条目,该条目将创建一个数组输入。 Add "com.orbotix.robotprotocol" as a String item in the array.
将“com.orbotix.robotprotocol”添加为数组中的String项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.