NSMutableArray *mySprites = [[NSMutableArray alloc] init];
// array is mutable so you can add to it
[mySprites addObject: newSprite];
// objective c syntax has improved, you can now access elements with the following syntax
CCSprite *mySprite = mySprites[0];
Cocos2d: How can I dynamically change size of array of CCSprite objects?
-
09-10-2022 - |
Domanda
For example: I made this array to keep all my CCSprites:
CCSprite *Enemy[20];
I figured it would be okay, since I would have no more than 20 enemies, but now I want to be able to increase the size of it, once it's filled with objects, to be 40.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow