Create a texture atlas on-the-fly?

With LibGDX, I use a mechanism of generating texture atlases on-the-fly when running the desktop build. I have the individual textures in a single folder, and when the desktop build is launched, it takes all the files, generates the texture atlas and puts it into the resource folder.

Is there a way to do this in Cocos2D-X? If so, how?

You need to use SpriteFrameCache. It can load texture atlases which consist of two files: an image itself and a plist-file describing the individual sprites in the atlas.
To generate a texture atlas you’ll need a proper software which can export these files or write one yourself (which is not too complex). Take a look at:
Zwoptex ($10, Mac OS only)
TexturePacker ($40, Win, Mac, Linux)
ShoeBox (free, Adobe Air, lots of other features)

UPD. Well, it’s not so ‘on-the-fly’ as the title says. But in the post itself you stated that packing should happen during the build, which can be done easily with the tools I listed.

Thanks for your reply. Is it possible to load the texture atlases generated by LibGDX’s TexturePacker2? I have a toolchain done that calls a batch file which in turn generates the texture atlas files (.png + .json) to the resource folder before the build.

IIRC it does not support the formats used by cocos2d-x.