Hi! I am working on an awesome new app and I have a question. In my app, I have a CCSprite subclass file (I need to create an instance of this a lot). This file will control everything about itself, eg. shooting or something in that nature depending on realtime game play elements... So I have some timers and statements that will check whether the conditions are right for something to occur, and when they are, I do this:
// creates a new bullet sprite
CCSprite *bullet = [CCSprite spriteWithFile:@"bullet.png"];
// assigns its position to the sprites position
bullet.position = self.position;
// get the current instance of the gamescene class
GameScene *scene = [GameScene node];
// add the bullet to the gamescene class
[scene addChild:bullet];
The code seems right, except it isn't adding it to the GameScene layer. When I do GameScene *scene = [GameScene node]; Does that create a new instance of the GameScene class? That's the only explanation for this behavior. If it does, how do I go about accessing the current instance of the GameScene class, so I can do interaction with it? I know this is possible, I'm just not sure how. I have tried many many ways, but they all have the same result. How would you go about doing this? Please help if you can. Thanks in advance!