I have a basic misunderstanding of pointers thing . I want to create many sprites, and i want them to be known to all class . What i did-and its kind of a miracle that it works is this :
I defined in the .h file :CCSprite *brokenBox; , so all class can see him.
Later , i have a function that create many of him , and add a body to each one .
-(void)someF
{
brokenBox=[CCSprite spriteWithFile:@"brokenBox.png"];
brokenBox.tag=5;
brokenBox.position=ccp(point.x*relativeX, point.y );
//now attach abody to him
....
....
[self addChild:brokenBox];
}
Now this function is being called many times (many boxes are here). What i dont understand is how can a single pointer change the file it points on again and again, and how is that i can add him as a child again and again ? Does he creates many pointers ?
What is the correct way to work so i can have access to all these sprites ?
(now to access them i do : [self getChildByTag:5]; and they all have the same tag=5.
Thanks a lot .