TexturePacker and cocos2d-js?

TexturePacker and cocos2d-js?
0.0 0



Can anyone tell me the best format to export from texture packer when building a project with cocos2d-js?

In c++ (cocos2d-x) I used to do this:

ZipUtils::setPvrEncryptionKeyPart(0, 0x98347586);
ZipUtils::setPvrEncryptionKeyPart(1, 0x87236763);


But it looks like I’m out of luck with this format in javascript ??


Looks like nobody could be bothered to reply to this, so here is what I did:

In texture packer I removed protection.

Then in advanced settings set:

Texture -> Pixel Format to RGBA8888
Texture -> Texture Format to PNG-32
Sprites -> Shape Padding to 23

I haven’t had time to test other export types but this one works.



You still can use the pvr.ccz format with Cocos2d-JS

add this code in /Classes/AppDelegate.cpp

bool AppDelegate::applicationDidFinishLaunching()
// initialize director
auto director = Director::getInstance();

// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);

ZipUtils::setPvrEncryptionKey(0x98347586, 0x87236763, 0x98347586, 0x87236763);

preload the image, can do it at app initialise

var plist_array =
		image1 : "res/plist1.plist",
		image2 : "res/plist2.plist"

var pvr_array =
		image1 : "res/pvr1.pvr.ccz",
		image2 : "res/pvr2.pvr.ccz"

var resource_array = [];
for (var i in plist_array) 
for (var i in pvr_array) 

function preload()
	for ( var key in plist_array)
	    cc.spriteFrameCache.addSpriteFrames(plist_array[key], pvr_array[key]);

You can preload the image with this if needed

	cc.LoaderScene.preload(resource_array, function ()
	}, this);

in JS you load the sprite as

var frame = cc.spriteFrameCache.getSpriteFrame("image_name.png");
new cc.Sprite(frame);


Thanks for your help.

I didn’t think that c++ “AppDelegate:: applicationDidFinishLaunching” was called if I was developing in Javascript?

so why would this line be called:

ZipUtils::setPvrEncryptionKey(0x98347586, 0x87236763, 0x98347586, 0x87236763);

Is there an equivalent in Javascript?


There is no equivalent in JS as i know.

But we do use the shared AppDelegate.cpp in iOS and Android project.

All files in /Classes are use. There will be SDKBOX cpp files in the folder too.
The Cocos2d-JS is using C++ code through binding.

The ZipUtils is included in /cocos/base/ZipUtils, you can check it.


I’m confused by how it would call the AppDelegate methods. When I run “cocos run -p web” I thought it just called JS code? my project is web only.


I didnt know you using it for web only.

I think the pvr.ccz format is still useable with the code above, but with the protection removed.


In the end I just used PNG-32 without compression or protection.