0

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

1 回答 1

0

您正在寻找的二传手看起来像这样。-

[self setIsTouchEnabled:YES];

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

self.isTouchEnabled = YES;

编辑

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

于 2013-09-12T13:45:12.580 回答