2012-01-30 8 views
1

我目前正在試驗各種輸入控件,並且偶然發現了SneakyInput,我正在嘗試使用它。SneakyInput/SneakyButton

不幸的是,當我加入一個SneakyButton(只是一個按鈕)層,並出現以下錯誤消息在整個應用程序崩潰:

+[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c 2012-01-30 10:00:50.881 OpenSpace[588:1be03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c'

我已經撞了我的頭周圍這幾個小時並試圖以很少的喜悅Google解決方案。任何幫助在這裏將不勝感激,爲什麼,它爲什麼會崩潰?

環境:2.0的cocos2d-β,OS X 10.7.2,iOS的5.0

代碼:

-(void) addFireButton { 
float buttonRadius = 80; 
CGSize screenSize = [[CCDirector sharedDirector] winSize]; 

fireButton = [[[SneakyButton alloc] initWithRect:CGRectZero] autorelease]; 
fireButton.radius = buttonRadius; 
fireButton.position = CGPointMake(screenSize.width - buttonRadius, buttonRadius); 
[self addChild:fireButton]; 
} 

錯誤消息完整:

2012-01-30 10:00:50.684 OpenSpace[588:1be03] cocos2d: cocos2d v2.0.0-beta2 
2012-01-30 10:00:50.685 OpenSpace[588:1be03] cocos2d: Using Director Type:CCDirectorDisplayLink 
[Switching to process 588 thread 0x1f113] 
2012-01-30 10:00:50.763 OpenSpace[588:1be03] cocos2d: animation started with frame interval: 60.00 
2012-01-30 10:00:50.766 OpenSpace[588:1be03] cocos2d: surface size: 960x640 
2012-01-30 10:00:50.850 OpenSpace[588:1be03] init: <OpenSpace = 093BFAE0 | Tag = -1> 
2012-01-30 10:00:50.857 OpenSpace[588:1be03] cocos2d: CCFileUtils: Warning file not found: spaceship-hd.png 
2012-01-30 10:00:50.864 OpenSpace[588:1be03] +[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c 
2012-01-30 10:00:50.881 OpenSpace[588:1be03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CCTouchDispatcher addTargetedDelegate:priority:swallowsTouches:]: unrecognized selector sent to class 0xfed9c' 
*** First throw call stack: 
(0x1c4c052 0x21e2d0a 0x1c4dadd 0x1bb2f00 0x1bb2ce2 0xb5438 0x1c4de1a 0x99e19 0x99dba 0x42890 0x345ed 0x1c4de1a 0x99e19 0x99dba 0x42890 0x26edd 0x90d7d 0x921c4 0x2a12db 0x2a11af 0x1c20966 0x1c20407 0x1b837c0 0x1b82db4 0x1b82ccb 0x29fd879 0x29fd93e 0x822a9b 0xb37d6 0x2525) 
terminate called throwing an exception[Switching to process 588 thread 0x1be03] 
sharedlibrary apply-load-rules all 
Current language: auto; currently objective-c 
+0

也許這就是爲什麼,從實況到cocos2d的V2.0:CCActionManager,CCScheduler,CCTouchDispathcer(IOS)和CCEventDispatcher(Mac)沒有更長的單身人士。相反,它們是CCDirector的屬性。 – clops 2012-02-01 12:16:54

回答

1

我終於設法解決了這個問題,對於那些感興趣的解決方案是將CCTouchDispatcher的所有引用替換爲CCDirector的屬性。在cocos2d 2.0版中,CCTouchDispatcher不再是單例,而是CCDirector的一個屬性。

我已付出github上SneakyInput庫並直接加入我的修正有

https://github.com/clops/SneakyInput

+0

這裏是我做的實際更改 - https://github.com/clops/SneakyInput /提交/ 318939caa03ce7435f1a46079464104737441ecc – clops 2012-02-01 12:53:23

2

SneakyInput是爲Cocos2D中v0.99書面/1.0。它可能不適用於Cocos2D 2.0,因爲CCTouchDispatcher的API可能已更改。至少這就是錯誤消息所說的,CCTouchDispatcher上沒有這樣的方法addTargetedDelegate:priority:swallowsTouches:

除非您需要或想要使用着色器程序,否則我會建議暫時使用Cocos2D v1.x。 SneakyInput與v1.x很好地工作

+0

謝謝,就是這樣!我昨天晚上通過重新開始從頭開始用cocos 2d 1.1 :)偶然發現了這個問題: – clops 2012-01-31 09:59:29

+0

但是,對於0.99以上的任何東西都不起作用:( – clops 2012-01-31 10:54:21