【发布时间】:2012-08-27 07:15:35
【问题描述】:
我正在尝试将 Sphero 连接到我正在构建的 Cocos2d 游戏。 Sphero 有一些很好的documentation 和示例,我可以运行示例代码。我从一个 cocos2d 项目开始,并添加了 Sphero 框架。我无法获得对球的基本命令。我相信问题出在这个函数上:
-(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];
}
(其余代码在链接中)我相信它与NSNotificationCenter有关。我从 CCLayerColor 调用此代码,而不是像演示那样使用 UIViewController。我收到此错误:
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
(已在Sphero IOS Forum 中回答)
【问题讨论】:
-
你确定
setupRobotConnection方法被调用了吗? -
是的,因为我添加了 onEnter 和 onExit 方法并在其中调用了 [self appDidBecomeActive:nil] 和 [self appWillResignActive:nil],所以正在调用这些方法。
标签: ios objective-c uiviewcontroller cocos2d-iphone sphero-api