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?


closed as off-topic by Anko, bummzack, congusbongus, Seth Battin, MrCranky Aug 13 '14 at 13:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – bummzack, Seth Battin, MrCranky
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ This question may be relevant. \$\endgroup\$ – Anko Aug 8 '14 at 20:46
  • \$\begingroup\$ ya, I guess the answer is no, then. I was looking for something like the wonderful Tiled or Particle Designer. Probably an opportunity in the market place to build a tool that does this. Wouldn't be hard. \$\endgroup\$ – gdbj Aug 8 '14 at 20:54
  • \$\begingroup\$ @GregoryJohnson Questions about which technology to use are considered off-topic here. That being said: maybe you should check out SpriteBuilder (formerly CocosBuilder). \$\endgroup\$ – bummzack Aug 10 '14 at 7:02

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.

  • 1
    \$\begingroup\$ yes, this is the method I would go with... or actually, JSON would be better, since I would want to have the type of sprite loaded dynamically as well. As I said above, it's probably really easy to put a GUI around this idea. Countless side-scrolling games have this concept. I was looking for a GUI based tool to help put the patterns together... point and click. Apparently someone out there thinks this is a dumb question tho. haha... dunno, seems like a good idea to me! \$\endgroup\$ – gdbj Aug 10 '14 at 3:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.