xcode - How to add multiple CCSprites inside CCArray -


if example had fruits in game , add fruit ccsprites ccarray how that?

say have following code:

ccsprite *apple = [ccsprite spritewithfile:@"apple2.png"]; ccsprite *banana = [ccsprite spritewithfile:@"banana2.png"];  

and ccarray:

ccarray *fruitsarray = [ccsprite spritewithfile:@"banana.png", @"apple.png", nil];// why not working?  self.fruitsarray = [ccarray arraywithcapacity:10]; 

i want fruitsarray have capacity of 10, should hold 10 apples , bananas.

any appreciated!

not working because not valid syntax calling spritewithfile function:

 [ccsprite spritewithfile:@"banana.png", @"apple.png", nil]; 

syntax:

+(id) spritewithfile:(nsstring*)filename; // returns object of ccsprite class 

« why can't derive ccsprite class , override spritewithfile on need basis?

 or 

« why can't add each object this?

   ccarray *fruitsarray = [ccarray array];    ccsprite *apple = [ccsprite spritewithfile:@"apple2.png"];    ccsprite *banana = [ccsprite spritewithfile:@"banana2.png"];      [fruitsarray addobject: apple];           [fruitsarray addobject: banana]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -