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.

Previously I was using simple Texture for sprite based animations, but that did not provide support for images which were not in the power of 2. TexturePacker provides with the ability to load all the images at once, and then fetch the required image from an imageatlas.

That said, I followed a couple of tutorials from the Libgdx wiki and it works well till the loading part. But I suppose during rendering, it is causing some problem. This is how I am loading the images into the texturepacker in my desktop project:

private static final String INPUT_DIR = "../Drop-Android/assets/images";
    private static final String OUTPUT_DIR = "../Drop-Android/assets/image-atlases";
    private static final String PACK_FILE = "pages-info";
    public static void main(String[] args){
        LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
        cfg.title = "Drop";
        cfg.width = 800;
        cfg.height = 480;

        Settings settings = new Settings();
        settings.maxWidth = 512;
        settings.maxHeight = 512;
        TexturePacker2.process(settings, INPUT_DIR, OUTPUT_DIR, PACK_FILE);
        new LwjglApplication(new Drop(), cfg);
    }

Question: Do I have to create pages-info i.e. the PACK_FILE manually in the images-atlases folder? If I do not, it throws File not found exception.

I happen to create pages-info file in the image-atlases folder and the following files are generated: pages-info.png and 'pages-info.atlas'. While, pages-info files is empty, the .png and .atlas files have the images and JSON image data, respectively.

This is what I am using to extract the textureregions out of the pages-info file (which is empty):

TextureAtlas ta = new TextureAtlas(Gdx.files.internal("image-atlases/pages-info"));
        imageOneRegion = ta.findRegion("image1.png");
        imageTwoRegion = ta.findRegion("image2.png");

As expected, it returns a nullpointerexception when drawing the textureregion. I am running out of ideas here, any help and ideas?

share|improve this question
1  
unless you named your image( also the region name ) image.png.png it you omit the extention. –  Sidar Jun 18 '13 at 17:24
add comment

1 Answer

up vote 3 down vote accepted

The textures are named as in the .pack file, without extensions. Try using "image1" instead of "image1.png".

If you watch your ta variable using the debug tool you should be able to see the names of textures actually loaded.

share|improve this answer
add comment

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.