Hi once again,
Seriously progressing on this game engine now, and at a stage where everything so far works in the console, but I've run into a problem when trying to get some visual feedback.
Essentially, I have a very dynamic superclass for my game engine which I subclass to define individual levels, many of which will use several totally different sprite sheets for characters. So, I am using an NSMutableArray to store multiple instances of AtlasSpriteManager, in this format:
NSMutableArray (
NSArray (
(NSString*) filename,
(AtlasSpriteManager*) ASM,
nil
)...
)
Loaded character classes contain a value — (NSString*) [class requiredSpriteManager] — that the engine pulls in order to determine which sprite sheet to load its graphics from. In theory this has not been a problem, but my graphics are now not displaying for uncertain reasons.
I believe this the is correct approach:
AtlasSpriteManager* ASM = [AtlasSpriteManager blahblah];
AtlasSprite* AS = [AtlasSprite spriteWithRect: assumedRect spriteManager: ASM];
[ASM addChild: AS];
[self addChild: ASM];
However, as mentioned, since I am loading sprite sheets dynamically, I am doing this instead (where [self sheets] is the NSMutableArray structure described above) on scene load:
NSEnumerator* sms = [[self sheets] objectEnumerator];
NSArray* sm;
int i = 0;
while(( sm = [sms nextObject] ))
{
[self addChild: [sm objectAtIndex: 1] z: i++];
}
...and then adding AtlasSprites later based on separate events.
Is this totally arse about face and am I screwing this up from the start by trying to be clever with arrays, or is it more likely that I'm getting something else wrong?