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