Just try to share my experience here in case anyone is interested.
As we know, .pvr or .pvr.ccz file is much smaller than png, and Texture Packer actually supports exporting for Spine.
However, even though the pvr file is smaller, the textures take the same size as PNG after being applied in your game. They are just smaller on disk anyway.
TexturePacker has an option to set pixel format to PVRTC2/PVRTC4, which provides kind of a lossy compressed texture and takes much less memory in runtime. Unfortunately, if you set the pixel format to PVRTC2/4 and try to export, it's going to say the format is not supported for Spine (not supported for libgdx actually).
Ok, I'm not doing anything fancy here, just need to modify a few lines in _spAtlasPage_createTexture to load PVRTC2/4 texture from SpriteFrameCache install of just addImage() :
Texture2D* texture = NULL;
SpriteFrame* pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(path);
if (pFrame)
{
texture = pFrame->getTexture();
}
else
{
texture = Director::getInstance()->getTextureCache()->addImage(path);
}
texture->retain();
self->rendererObject = texture;
self->width = texture->getPixelsWide();
self->height = texture->getPixelsHigh();
In order for this to work, we need to get the sprite frames ready before creating skeleton, and those frames should be from the .pvr.ccz files created by TexturePacker. Here are my steps to create the "identical" pvr.ccz files from the .png files form Spine.
Just export .json, .atlas, and .png files as usual from spine. MAKE SURE SETTING PAGE WITH/HEIGHT to 512/512 (both max and min), and check "Square" "Premultiply alpha". So we can make sure the exported PNG files are 512x512
In TexturePacker, add the path for your .png files. MAKE SURE the relative path is the same as your .json/.atlas files.
In TexturePacker, set the following:
Data format: cocos2d
Texture Format: PVR+zlib
Premultiply Alpha: yes
Pixel format: PVRTC2 or PVRTC4
Fixed Size W/H: 1024 (so it will contain exactly 1 atlas page)
Forced Squared: yes
Multipack: yes
Allow rotation: NO
Trim Mode: NO
ok, then export
- in the genrated .plist file, make sure the path for the sprite frames are the same path passed to _spAtlasPage_createTexture (spAtlasPage* self, const char* path). If not, change the path in your texturepacker and repeat.