Ayuda: – : selector no reconocido enviado a la instancia 0x257f50

Actualmente estoy haciendo los tutoriales en el libro: "aprender iPhone e iPad cocos2d Game Development" por Steffen Itterheim y he tenido problemas con el código del tutorial DoodleDrop, capítulo 4. He intentado encontrar el origen del problema, pero no puedo hacerlo

Aquí está el código que estoy usando:

#import "GameScene.h" @implementation GameScene -(void) spiderBelowScreen:(id)sender { NSLog(@">>spiderBelowScreen<<"); // Make sure sender is actually of the right class NSAssert([sender isKindOfClass:[CCSprite class]], @"sender is not a CCSprite!"); CCSprite* spider = (CCSprite*)sender; // Move the spider back up outside the top of the screen CGPoint pos = spider.position; CGSize screenSize = [[CCDirector shanetworkingDirector] winSize]; pos.y = screenSize.height + [spider texture].contentSize.height; spider.position = pos; } -(void) runSpiderMoveSequence:(CCSprite*)spider { NSLog(@">>runSpiderMoveSequence<<"); // Slowly increase the spider speed over time numSpidersMoved++; if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f) { spiderMoveDuration -= 0.1f; } // This is the sequence which controls the spiders' movement CGPoint belowScreenPosition = CGPointMake(spider.position.x, [spider texture].contentSize.height); CCMoveTo *move = [CCMoveTo actionWithDuration:spiderMoveDuration position:belowScreenPosition]; CCCallFuncN *call = [CCCallFuncN actionWithTarget:self selector:@selector(spiderBelowScreen)]; CCSequence *sequence = [CCSequence actions:move, call, nil]; [spider runAction:sequence]; } -(void) spidersUpdate:(ccTime)delta { NSLog(@">>spidersUpdate<<"); // Try to find a spioder which isn't currently moving for (int i = 0; i < 10; i++) { int randomSpiderIndex = CCRANDOM_0_1() * [spiders count]; CCSprite *spider = [spiders objectAtIndex:randomSpiderIndex]; // If the spider isn't moving it won't have any running actions if ([spider numberOfRunningActions] == 0) { // This is the squense wich controls the spiders' movement [self runSpiderMoveSequence:spider]; // Only onbe spider should start moving at a time break; } } } -(void) resetSpiders { NSLog(@">>resetSpiders<<"); CGSize screenSize = [[CCDirector shanetworkingDirector] winSize]; // Get any spider to get its image width CCSprite *tempSpider = [spiders lastObject]; CGSize size = [tempSpider texture].contentSize; int numSpiders = [spiders count]; for (int i = 0; i < numSpiders; i++) { // Put each spider at its designated position outside the screen CCSprite *spider = [spiders objectAtIndex:i]; spider.position = CGPointMake(size.width * i + size.width * 0.5f, screenSize.height + size.height); [spider stopAllActions]; } // Uschedule the selector just in case. If it isn't scheduled it wont do anything [self unschedule:@selector(spidersUpdate:)]; // Schedule the spider update logic to run at the given interval [self schedule:@selector(spidersUpdate:) interval:0.7f]; } -(void) initSpiders { NSLog(@">>initSpiders<<"); CGSize screenSize = [[CCDirector shanetworkingDirector] winSize]; // using a temporary spider sprite is the easiest way to get the image's size CCSprite *tempSpider = [CCSprite spriteWithFile:@"spider.png"]; float imageWidth = [tempSpider texture].contentSize.width; // Use as many spiders as can fit next to each other over the whole screen width int numSpiders = screenSize.width / imageWidth; // Initialize the spider array using alloc spiders = [[CCArray alloc] initWithCapacity:numSpiders]; for (int i = 0; i < numSpiders; i++) { CCSprite *spider = [CCSprite spriteWithFile:@"spider.png"]; [self addChild:spider z:0 tag:2]; // Also add the spider to the spider array [spiders addObject:spider]; } // call the method to reposition all spiders [self resetSpiders]; } -(void) update:(ccTime)delta { NSLog(@">>update:(ccTime)delta<<"); // Keep adding up the playerVelocity to the players's position CGPoint pos = player.position; pos.x += playerVelocity.x; // The player should also be stopped from going outside the screen CGSize screenSize = [[CCDirector shanetworkingDirector] winSize]; float imageWidthHalved = [player texture].contentSize.width * 0.5f; float leftBorderLimit = imageWidthHalved; float rightBorderLimit = screenSize.width - imageWidthHalved; // Preventing the player sprite from moving outside the screen if (pos.x < leftBorderLimit) { pos.x = leftBorderLimit; playerVelocity = CGPointZero; } else if (pos.x > rightBorderLimit) { pos.x = rightBorderLimit; playerVelocity = CGPointZero; } player.position = pos; } -(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { NSLog(@">>accelerometer<<"); // controls how quickly velocity decelerates (lower = quicker to change direction) float deceleration = 0.2f; // determines how sensitive the accelerometer reacts (higher = more sensitivity) float sensitivity = 6.0f; // how fast the velocity can be at most float maxVelocity = 550; // adjust velocity based on current accelerometer acceleration playerVelocity.x = playerVelocity.x * deceleration + acceleration.x * sensitivity; // we must limit the maximum velocity of the player sprite, in both directions if (playerVelocity.x > maxVelocity) { playerVelocity.x = maxVelocity; } else if (playerVelocity.x < -maxVelocity) { playerVelocity.x = -maxVelocity; } } +(id)scene { NSLog(@">>scene<<"); CCScene *scene = [CCScene node]; CCLayer *layer = [GameScene node]; [scene addChild:layer]; return scene; } -(id)init { NSLog(@">>init<<"); if ((self = [super init])) { CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self); self.isAccelerometerEnabled = YES; player = [CCSprite spriteWithFile:@"alien.png"]; [self addChild:player z:0 tag:1]; CGSize screenSize = [[CCDirector shanetworkingDirector] winSize]; float imageHeight = [player texture].contentSize.height; player.position = CGPointMake(screenSize.width / 2, imageHeight / 2); // scheduling the update method in order to adjust the player's speed every frame [self scheduleUpdate]; [self initSpiders]; } return self; } -(void) deallaoc { NSLog(@">>dealloc<<"); CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self); // The spiders array must be released, it was created using [CCArray alloc] [spiders release]; spiders = nil; // Never forget to call [super dealloc] [super dealloc]; } @end 

El resultado que obtengo (editado), incluido el NSLog que he incluido, es:

 2011-08-13 15:18:38.401 DoodleDrop[1751:707] >>update:(ccTime)delta<< 2011-08-13 15:18:38.404 DoodleDrop[1751:707] -[GameScene spiderBelowScreen]: unrecognized selector sent to instance 0x257f50 2011-08-13 15:18:38.407 DoodleDrop[1751:707] >>accelerometer<< 2011-08-13 15:18:38.417 DoodleDrop[1751:707] >>update:(ccTime)delta<< 2011-08-13 15:18:38.419 DoodleDrop[1751:707] -[GameScene spiderBelowScreen]: unrecognized selector sent to instance 0x257f50 

Me pregunto si hay alguien agradable que pueda ayudarme aquí.

Creo que necesitas usar @selector(spiderBelowScreen:) . Tenga en count que :