Reputation: 276
Im reading a tutorial to animate sprite sheet frames in objective-C, code below shows how to allocate and initialize a mutable array and loop through it using a for loop.
NSMutableArray *frames = [[NSMutableArray alloc]init];
for (int i=0; i<=10; i++) {
NSString *frameName = [NSString stringWithFormat:@"a%04i.png",i];
}
i can't understand how this piece of code works :
:@"a%04i.png",i
note that i have sprites name like this : a0001.png till ,a0031.png. simply tell me how a%4i works here ? thanks
Upvotes: 1
Views: 101
Reputation: 4919
the translation is not very hard:
:@"a%04i.png",i
@"a" + @"integerWith4digits" + @".png" == @"a0000.png";
i.e. if the integer is 1 then complete the integer by adding 3 zeros (0001), if the integer is 1111 or 1111..., then do nothing
Upvotes: 2