2014-10-18 93 views
0

當我嘗試通過取消註釋下面的函數(如文檔建議)來激活觸摸移動支持:Cocos3D handleTouch:ofType:不承認

///* 
-(void) ccTouchMoved: (UITouch *)touch withEvent: (UIEvent *)event { 
    [self handleTouch: touch ofType: kCCTouchMoved]; 
} 
//*/ 

我得到的編譯錯誤:

No visible @interface for 'CC3HelloWorldLayer' declares the selector 'handleTouch:ofType:' 

enter image description here

該函數在CC3layer繼承的CCLayer.h中聲明。

這個奇怪的錯誤是什麼原因造成的?

回答

1

handleTouch:ofType:方法在CC3Layer.m中定義爲受保護方法,需要在使用它的任何子類文件(它沒有公開可見性)中重新聲明。

由於疏忽導致CC3HelloWorldLayer.m文件中缺少重新聲明。我將在未來的版本中解決這個問題。

在此期間,以下內容添加到您的CC3HelloWorldLayer.m文件的頂部:

@interface CC3Layer (TemplateMethods) 
-(BOOL) handleTouch: (UITouch*) touch ofType: (uint) touchType; 
@end 

TileLayer.mCC3DemoMashUpLayer.m文件的例子。

... Bill

0

handleTouch:ofType:不是在CCLayer.h中聲明爲(public)方法,或者CC3HelloWorldLayer類不是直接或通過其父類CC3Layer從CCLayer.h繼承。

你的確說這兩種都是這種情況,但我不能完全相信它,因爲這將是導致此錯誤發生的唯一原因。