I have a few questions regarding performance that i was hoping someone may be able to answer or how i could go about finding out performance differences within xcode??
regarding children that get used frequently throughout a layer (or the program) is it better to create a variable with retain property for the child and simply call the variable to make adjustments.. child.position = ccp(10,10);
or use getChild method each time you use it in each method.. like the following:
CCSpriteSheet *sheet = (CCSpriteSheet*)[self getChildByTag:kSheetTag];
CCSprite *child = (CCSprite*)[sheet getChildByTag:kChildTag];
child.position = ccp(10,10);
storing the tags in an enum. The latter is how i have gone about it.. may be a bit more typing but im assuming its better for performance.
Also regarding updating a Label.. I have a DataManager Singleton that stores a value for the score which changes with certain events. i could simply have in my step method something like the following:
NSString *scoreString = [NSString stringWithFormat:@"%d",(int)datamgr.score];
[scoreLabel setString:scoreString];
but this sets the score every time step is called.
I have a HudLayer which displays the score label.. when an event that alters the score occurs my GameLayer makes a method call to its delegate (GameScene) "updateScoreBy:(int)amount" then in turn tells HudLayer to setString of the scoreLabel.
A bit long winded but is this substantially better for performance or am i wasting time and typing too much??
also.. i have tried to make a call to my layers parent (The GameScene) instead of declaring it as the layers delegate.. but i cant seem to get it to works.. is this even possible if so How?
thanks for your time in advance
Byron