得到一个奇怪的错误,我正在使用cocos2d

时间:2013-09-12 13:38:22

标签: ios cocos2d-iphone

我得到此错误实例方法'-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;
}

1 个答案:

答案 0 :(得分:0)

你正在寻找的二传手看起来像这样.-

[self setIsTouchEnabled:YES];

(注意缺少的'是')。或者你可以直接写

self.isTouchEnabled = YES;

修改

正如@Grzegorz Krukowski所说,setIsTouchEnabled目前已被弃用,setTouchEnabled实际上是cocos2d 2.x中使用的方法。我猜你可能正在使用2.x之前的版本。