2014-10-18 86 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继承。

你的确说这两种都是这种情况,但我不能完全相信它,因为这将是导致此错误发生的唯一原因。