I have a problem passing a variable to a function with parameters:
-(void)addCharacterToScene:(NSString *)name withFrames:(CCSpriteFrame*)frames,... { va_list args; va_start(args, frames); id arg = va_arg(args,CCSpriteFrame*); int i=1; while (arg) { NSString *frame_name = [NSString stringWithFormat:@"%@_%i",name,i]; NSLog(@"%@ \n%@",frame_name, arg); [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFrame:arg name:frame_name]; arg = va_arg(args,CCSpriteFrame*); i++; } va_end(args); }
The problem is that the function skips the first argument. My function call is as follows:
[self addCharacterToScene:@"wiz" withFrames:wizardFrame1,wizardFrame2,wizardFrame3,nil];
I can pass the dummy object to the first position and give the desired result, but there should be a better solution. Thank you
source share