我得到此错误实例方法'-setTouchEnabled:'未找到(返回类型默认为'id') 我不知道是什么导致它,任何帮助将不胜感激:) 继承了我的代码对不起,如果它凌乱
- (id) init
{
if ((self = [super init])) {
CGSize winSize = [CCDirector sharedDirector].winSize;
CCSprite *player = [CCSprite spriteWithFile:@"start.png"];
player.position = ccp(player.contentSize.width/2, winSize.height/2);
[self addChild:player];
[self schedule:@selector(gameLogic:) interval:0.5];
[self setTouchEnabled:YES];
_monsters = [[NSMutableArray alloc] init];
_projectiles = [[NSMutableArray alloc] init];
// stuff that needs updating
[self schedule:@selector(update:)];
//labels
StrategyBullet = 10;
Strategyscore = 0;
CCLabelTTF *label2 = [CCLabelTTF labelWithString:@"Ninja stars " fontName:@"Arial" fontSize:15];
label2.position = ccp(400,310);
label2.color = ccc3(255, 0, 0);
[self addChild: label2 z:1];
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Score" fontName:@"Arial" fontSize:15];
label.position = ccp(30,310);
label.color = ccc3(255, 0, 0);
[self addChild: label z:1];
StrategyscoreLabel = [CCLabelTTF labelWithString:@"0" fontName:@"Arial" fontSize:14];
StrategyscoreLabel.position = ccp(65, 310);
StrategyscoreLabel.color = ccc3(255, 255, 255);
[self addChild:StrategyscoreLabel z:1];
StrategyBulletLabel = [CCLabelTTF labelWithString:@"0" fontName:@"Arial" fontSize:14];
StrategyBulletLabel.position = ccp(450, 310);
StrategyBulletLabel.color = ccc3(255, 255, 255);
[self addChild:StrategyBulletLabel z:1];
}
return self;
}
答案 0 :(得分:0)
你正在寻找的二传手看起来像这样.-
[self setIsTouchEnabled:YES];
(注意缺少的'是')。或者你可以直接写
self.isTouchEnabled = YES;
修改强>
正如@Grzegorz Krukowski所说,setIsTouchEnabled
目前已被弃用,setTouchEnabled
实际上是cocos2d 2.x
中使用的方法。我猜你可能正在使用2.x之前的版本。