1
\$\begingroup\$

I've just bought Oryx's Roguelike Tileset pack and I use LibGDX (flixel-gdx to be precise).

My question is, given this pre-made sprite sheet format, what's the best way to integrate the sprites into the game I'm making?

LibGDX uses TexturePacker, but that needs a special .pack file with metadata like where the sprites are located. I can't see a way to generate these from an existing spritesheet.

Is there any other recommended technique?

\$\endgroup\$
1

2 Answers 2

1
\$\begingroup\$

I would also be interested in hearing how other people manage their artwork in libGDX.

I'm sure most users of libGDX will encounter this as soon as they try to use spritesheets from other sources (not made in-house, with libGDX in mind).

I had the same issue, trying to use resources from OpenGameArt.org.

I have solved this problem two different ways.
The first was to use a spritesheet unpacker, which basically allows you to provide parameters for padding round the margins, the size of the tiles/sprites, then the horizontal and vertical padding between the sprites. The unpacker then extracts the individual files into a directory, which you can then re-pack using libGDX-aware utility, to take the directory of individual files (which you should rename before this, so the atlas you get back will have useful aliases) and re-build them into a single spritesheet with accompanying atlas (pack file). I can't find the one I used initially, but here's another one that's actually a bit more flexible: Alferd Spritesheet Unpacker

The second method, and the one I'm using on my current work, is to manage my assets myself for each level, via an XML file that I load at level-load-time. I implemented a custom asset manager class that takes XML files wherein I provide the spritesheets, referenced by a name, then provide named textures or sprites which take the spritesheet name, then an offset and size into that spritesheet to get the individual sprites. This sounds tedious, but once you standardize your artwork, it's very painless. Then I have another XML node-type for animations, which allows me to specify individual frames from one or more spritesheets. As long as my artist doesn't move things around, they are free to make tweaks, without having to modify the XML asset file for the level. This method works particularly well in my current project, which is a 32x32 tileset game, where I just keep my art assets in grids in .PNG files whithout any padding. Then I refer to the assets by tile coordinates, rather than pixel offsets and sizes.

Even though libGDX provides these helpful tools (packed spritesheets / texture atlases / etc...), in my limited experience, I've found I like my way better.

Your mileage may vary. If you've just got a set of fixed assets, like the set you purchased, you may want to just go through the unpack/rename/re-pack process I mention in my first method above. If you want more flexability, you'll probably wind-up doing your own asset manager as I did in method two, above, or at least a customized wrapper around libGDX's built-in asset manager.

Good luck!

\$\endgroup\$
0
\$\begingroup\$

You could pretty easily manually type up an atlas (the metadata pack file that TexturePacker generates.) It's just a plain text file with entries that point to specific images contained in the packed png. Look at a sample .atlas file and just Notepad++ up your own that imitates the format and points to the individual sprites on your sheets.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .