I have 1 png of many different textures. I want to use these textures in my iphone game using cocos2d. I found the program "Zwoptex" where you can combine many textures to one png and create a plist file that you can use in your program.

But if you have already a png file how do you get all these textures out of this file automatically OR how do I create a plist file from this png file?

  • \$\begingroup\$ The last time I checked, PNG is a 2D graphic format that includes some nice features like true alpha-blending (which GIF and JPeG do not). In other words, the PNG is the texture. If it's a big file with many textures, you'll probably be better off just cropping them out manually and saving them in separate files for easier access later. \$\endgroup\$ – Randolf Richardson Jul 22 '11 at 1:33
  • \$\begingroup\$ @Randolf You're probably not better off cropping manually .. if the spritesheet is in reasonable rectangles, cropping a spritesheet in software is easy. \$\endgroup\$ – bobobobo Jul 22 '11 at 18:05
  • \$\begingroup\$ @OP is the size of the textures regular rectangles? (32x32's, for example?) Can you post the spritesheet? \$\endgroup\$ – bobobobo Jul 22 '11 at 18:06
  • \$\begingroup\$ @bobobobo: I was thinking that perhaps the .PNG file represented a grid of say 4 (2x2) or 9 (3x3) different textures. \$\endgroup\$ – Randolf Richardson Jul 22 '11 at 21:41

Looks like Zwoptex uses XML files to define sprites in a file. Unless the program has some kind of wizard for creating a new XML file from an existing PNG, you'd have to create this XML file yourself. You can find the specifications for creating one here: http://zwoptexapp.com/documentation, which includes a sample file.

If there isn't a wizard, you're best bet is to break apart all your images to have Zwoptex put them back together (and in the process create it's XML sprite definition file). Gimp is a free photo editor if you need one, fairly simple to use. To break apart your images, just use the Free Select Tool, select a sprite, CTRL + C, then go to File->Create->From Clipboard. Then simply save the new image with an appropriate name.

Good luck!

| improve this answer | |
  • \$\begingroup\$ Ty for your answer, doing it manually looks like a lot of work that I am trying to avoid, do you know another (free) program that can do this automatically? \$\endgroup\$ – user748790 Jul 22 '11 at 9:43
  • \$\begingroup\$ Multimedia Fusion and GameMaker include ways to import sprite sheets, but the tiles need to be the same size. I would therefore also recommend GIMP, but using a different technique : Make the background transparent (with the magic wand), then select each sprite with these params (Threshold 255, "Select Transparent Areas" off, Anialiasing off). It should be quicker than using the free select (only one click). \$\endgroup\$ – Jonathan Connell Jul 22 '11 at 11:17
  • \$\begingroup\$ @3nixios, nice tip! I'll have to use that in the future. \$\endgroup\$ – MichaelHouse Jul 22 '11 at 15:21
  • \$\begingroup\$ @user748790, I agree, manually would be a huge waste of time. However, I don't know of any other sprite sheet makers for iPhone. I would suggest going ahead with using GIMP and 3nixios's technique, it would be pretty quick. Additionally, you probably already found it, but here's a nice tutorial, once you've got your images sorted. \$\endgroup\$ – MichaelHouse Jul 22 '11 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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