0
我已經制定了一個將字符串對象與數組中的枚舉的每個成員相匹配的方法。我想添加精靈到每個成員的bArray匹配與他們各自的字符串作爲精靈圖像。我怎樣才能做到這一點?從字符串數組中製作ccsprites
+ (NSArray *)names
{
static NSMutableArray * _names = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_names = [NSMutableArray arrayWithCapacity:20];
[_names insertObject:@"image1.png" atIndex:image1];
[_names insertObject:@"image2.png" atIndex:image2];
[_names insertObject:@"image3.png" atIndex:image3];
[_names insertObject:@"image4.png" atIndex:image4];
[_names insertObject:@"image5.png" atIndex:image5];
[_names insertObject:@"image6.png" atIndex:image6];
.
.
.
.
});
return _names;
}
-(void)spriteGroups {
NSArray* sgArray;
sgArray = [[spManager names] objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];
CCSprite* groupSprite = [CCSprite spriteWithFile:[sgArray[0]]];// this gives me an expected identifier error. I guess this is not the right way
for (int i = 1; i > [sgArray count]; i++) {
}
}
非常感謝移除額外的方括號。我不知道我是如何錯過的。 – oopology 2013-03-21 05:47:19