So I built my first game app, and it was a lot of fun. I'm really trying to expand on some of the ideas, but I'm running in to some serious variable scope issue. What I want to do is encapsulate a CCSprite as an instance variable, and then modify it in my "HelloWorldLayer"
In my header:
@interface HelloWorldLayer : CCLayer
{
CCSprite *mySprite;
}
and in my HelloWorldLayer.m I run into the problem where if I try to do something like
- (id)init
{
CCSprite mySprite = [CCSprite initWithFile:@"spriteFile.png"];
}
I run into either
- Memory management issues
- Variable scope issues (overwriting etc.)
What I want to do is be able to declare the sprite, and then change certain properties in other methods such as ccTouchesMoved. How can I do this?
P.S. I'm sorry if the code is a little rough around the edges, I have been writing Ruby for the last two weeks and I'm a little out of it with reference to objective.