I have no idea why this code does not work. The whole idea about it is to make the value bigger until it’s bigger than score.
if(score > height && rocketlaunch == false)
{
@try
{
height = [self makebigger:height];
}
@catch (NSException *exception)
{
height = height + 4000;
}
upgradeRocket.center = CGPointMake((rand()%200), -50);
rocketlaunch = true;
}
-(int)makebigger:(int)heightnr {
heightnr = heightnr + (1000 * rand() %5);
if(score > heightnr) {
[self makebigger:heightnr];
return heightnr;
} else {
return heightnr;
}
}
Does anyone know how to fix this? Or have a alternative way?
P.S.
The error displayed was:
Implicit conversion of int to id is disallowed with ARC
and
Incompatible integer to pointer conversion returning int from a function with result type id
Thank you in advance.
EDIT:
It works this way thank you very much 🙂
EDIT:
I got a new problem hard to solve:
this gives the error > tread 1 exc bad acces code = 2
change
-makebigger:(int)heightnrto- (int)makebigger:(int)heightnr.You have to specify the return type.
And you have to return something if the condition is true, too.
Until now I didn’t even know it was possible to use no return type. But apparently it is.