2012-08-27 49 views
3

我正在嘗試將Sphero連接到我正在構建的Cocos2d遊戲。 Sphero有一些很好的documentation和示例,我可以運行示例代碼。我從一個cocos2d項目開始,並添加了Sphero框架。我無法獲得基本的控球權。我相信這個問題是這樣的功能:Cocos2d-iphone - 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

+0

確定'setupRobotConnection'方法被調用? – Kreiri

+0

是的,因爲我添加了onEnter和onExit方法,並且在它們中調用了[self appDidBecomeActive:nil]和[self appWillResignActive:nil],所以方法被調用。 – Alex

回答

6

You need to add the external accessory protocol string to your 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. Add "com.orbotix.robotprotocol" as a String item in the array.