I'm wondering if anyone has suggestions for how to manage the positioning of many sprites in pre-set and complicated patterns? Currently the brute-force method is to painstakingly code each sprite into its place. However, ideally, I would like to not have to code it directly, but instead read the sprite positions in from a file (or some other data source). Are there any solutions out there that do this?
You're on iOS using Objective-C, I assume, so use PLIST files.
XCode has an excellent PLIST editor. NSDictionary lets you load a PLIST file with a single method call:
NSDictionary * plistDict = [NSDictionary dictionaryWithContentsOfFile:@"test.plist"];
From that, it is very easy to automate. Just load the dictionary and set the sprite position:
double x = [[plistDict objectForKey:@"sprite_pos_x"] doubleValue]; double y = [[plistDict objectForKey:@"sprite_pos_y"] doubleValue]; sprite.position = ccp(x,y);
If you change the sprite position in the PLIST, there is no need to recompile. With a bit of work, you can even add runtime reloading of modified files.