Greetings Community,
I am looking for some advice on some cocos2d related concepts, and keep in mind my prior styles were an outcome of C#/C++. My questions are namely in architecting communication between layers and code infrastructure but I will just list my questions in hopes of advice
1. Normally, I call an objects function with an instance variable. ie: The Menu class would have a reference to the main game class, and would call something like StartGame when the Start button is pushed. In cocos I have a GameScene which contains 2 layers: Menu and Game as the menu is just a floating menu over the game as opposed to a separate scene.
It seems the standard is to make calls through a NSNotificationCenter; but is this un-needed overhead to have listeners in what is an effective way of making calls in other classes? or is it frowned upon to pass instance pointers around?
2. I have a simple text file which lists all my precached 'master' sprites and animation files. Upon reading this file I dynamically create sprites during the game's LoadGame sequence. When loading animations this causes a loop of reading the path and creating an Animation using the addFrameWithFileName. I am afraid that under the hood this may use up my texture space as projects grow larger in asset size. My guess is that this comes to a debate on using AtlasSpriteManager with a sprite sheet as opposed to having animations whose frames are in separate files.
In Essence, is this a bad style to have for all animations.
Animation *croakAnimation = [[Animation alloc] initWithName:@"croak" delay:0.1];
NSString *path;
for( int i = 1; i<37; i++ )
{
path = [NSString stringWithFormat:@"frog-croak-inflate%04d.png", i];
[croakAnimation addFrameWithFilename:path];
}
id croak = [Animate actionWithAnimation: croakAnimation];
3. Is there a more appropriate way to do a deep copy of a sprite ? For now, I have just created a spriteFromSprite call which creates a new Sprite based on the other's texture.
4. Should I register a tick once on the root GameScene and delegate the message to children or is it better that each object in the scene register the tick with the Director?
5. Any pointers on dealing with Landscape to Potrait switches during a transition? Going from SceneA to SceneB, I want SceneA to fade out, switch modes, and see Scene B fade in. I guess I could re-write the FadeTransitions to make this call but I feel transitions should not have code calling anything from the Director.
That is all I suppose, at least for the simplest of first timer games I am making. I appreciate any comments in advance.