我是目标c世界的新手,并且已经熟悉cocos2d框架。我正在尝试构建一个基本的touchEnabled粒子动画应用程序,它调用子类ccParticleMeteor。我在.m中收到以下编译器错误/警告,我无法重新配置我的代码以消除这些编译器错误。如果需要任何其他说明,请告诉我......谢谢!
`conflicting types for '-(BOOL)ccTouchesBegan:(NSSET *)touches withEvent:(UIEvent *) event'
Previous Declaration of '-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event'
conflicting types for '-(BOOL)ccTouchesMoved:(NSSel *)touches withEvent:(UIEvent *)event'
Previous Declaration of '-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event'
'UITouch' may not respond to '-LocationInView:'
Errors
INVALID INTIALIZER. @ CGPoint touch line
LOCATION UNDECLARED. @ CGPoint point line
`- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if( (self=[super init])) {
self.isTouchEnabled = YES;
emitter = [[CCParticleMeteor alloc] init];
emitter.texture = [[CCTextureCache sharedTextureCache] addImage:@"starry1.png"];
emitter.position = ccp(320, 480);
[self addChild: emitter];
}
return self;
}
-(BOOL) ccTouchesBegan: (NSSet *)touches withEvent:(UIEvent *)event {
[self ccTouchesMoved:touches withEvent:event];
return YES;
}
-(BOOL) ccTouchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint touch = [myTouch LocationInView:[myTouch view]];
CGPoint point = [[CCDirector sharedDirector] convertToGL:location];
emitter.position = ccp(point.x, point.y);
return YES;
`
答案 0 :(得分:1)
`conflicting types for '-(BOOL)ccTouchesBegan:(NSSET *)touches withEvent:(UIEvent *) event'
Previous Declaration of '-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event'
这告诉您方法签名不匹配。在这种情况下,它应该是:
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
换句话说,“touches”方法不会返回BOOL。