Hi everyone,
I'm currently trying my best to tidy up my code and reduce the number of functions I have. In doing so I would like to pass in an integer into my function that defines which sprite to use.
This is where I'm having a problem, using IF statements causes XCode to not see me declaring which sprite to use and gives me an declared error, and also list all of my sprite declarations as 'unused variables' warnings.
Ive tried declaring it before the IF statements but it doesn't allow me to redefine it.
//c is passed in when calling the function.
if(c == 1){
Sprite *block = [[Sprite spriteWithFile:@"green.png"] retain];
}
if(c == 2){
Sprite *block = [[Sprite spriteWithFile:@"red.png"] retain];
}
if(c == 3){
Sprite *block = [[Sprite spriteWithFile:@"blue.png"] retain];
}
[self addChild: block z:1 tag:blockSprite];
I'm pretty sure this is a simple fix I've spent a while trying different things, and Google'ing the problem but I cant quite get it to work.