AaronChapmanDev
AaronChapmanDev

Reputation: 124

cocos2D &lt not working

I have been asking a lot of questions lately, sorry. I get an error when &lt shows up.

-(void) SpritesDidCollide {

CCNode *player = [self getChildByTag:kTagPlayer];
CCNode *computer = [self getChildByTag:kTagComputer];

float xDif = computer.position.x - player.position.x;
float yDif = computer.position.y - player.position.y;
float distance = sqrt(xDif * xDif + yDif * yDif);

if (distance &lt 45;) {    //--------------------Right Here-------------------
    [self unschedule:@selector(SpritesDidCollide)];
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1 scene:[GameOver node]]];
}

}

Upvotes: 1

Views: 411

Answers (3)

Jer In Chicago
Jer In Chicago

Reputation: 828

Look at 'Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt'

your selector (SpritesDidCollide) isn't accepting ccTime...

change

-(void)SpritesDidCollide 

to

-(void)SpritesDidCollide:(ccTime)dt

and change

[self unschedule:@selector(SpritesDidCollide:)]; // Note added colon : after method name

May also need to change the schedule call and add the colon : where ever you initially set it up

[self schedule: @selector(SpritesDidCollide:)];

Upvotes: 1

0xDE4E15B
0xDE4E15B

Reputation: 1294

if (distance &lt 45;) {

Take a look again. To compare use comparison operators such as '==', '<', '>', '<=', '>='. Inside of brackets in your case we do not need ';'.
'(expression ;)' such construction is not acceptable.

if (distance < 45) {

Upvotes: 0

Lukman
Lukman

Reputation: 19164

Why not just:

if (distance < 45) { 

Upvotes: 4

Related Questions