我正試圖編寫一個方法來完成上述操作。我的紋理圖集包含超過500個紋理。當我將提取的紋理存儲在新的陣列中並記錄其描述時,陣列包含我正確命名的3個紋理加上原始Atlas包含的所有紋理。所有這些都被稱爲「'MissingResource.png'(128 x 128)」。從紋理地圖提取紋理選擇
我的問題是:如何只存儲我想要在新的數組中的3個紋理?下面是代碼:
-(void)createSelectedTexturesWith:(NSString*)ImageName;
{
int bgCount = 1;
NSMutableString *tempstring = [NSMutableString stringWithString:ImageName];
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"textures"];
NSMutableArray *Leveltextures = [[NSMutableArray alloc]init];
NSUInteger numImages = atlas.textureNames.count;
for (int i=1;i <= numImages; i++) {
[tempstring appendFormat:@"_%02d.png",bgCount];
NSString *textureName = [NSString stringWithString:tempstring];
SKTexture *temp = [atlas textureNamed:textureName];
[Leveltextures addObject:temp];
[tempstring setString:ImageName];
bgCount++;
}
NSLog(@"Leveltextures Content: %@",[Leveltextures description]);
}