Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Randolf Richardson Jul 22 '11 at 1:33
    
@Randolf You're probably not better off cropping manually .. if the spritesheet is in reasonable rectangles, cropping a spritesheet in software is easy. –  bobobobo Jul 22 '11 at 18:05
    
@OP is the size of the textures regular rectangles? (32x32's, for example?) Can you post the spritesheet? –  bobobobo Jul 22 '11 at 18:06
    
@bobobobo: I was thinking that perhaps the .PNG file represented a grid of say 4 (2x2) or 9 (3x3) different textures. –  Randolf Richardson Jul 22 '11 at 21:41

1 Answer 1

up vote 2 down vote accepted

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!

share|improve this answer
    
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? –  user748790 Jul 22 '11 at 9:43
    
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). –  Jonathan Connell Jul 22 '11 at 11:17
    
@3nixios, nice tip! I'll have to use that in the future. –  Byte56 Jul 22 '11 at 15:21
    
@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. –  Byte56 Jul 22 '11 at 15:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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