Cocos2d-x V4.0 released

@slackmoehrle @zhangxm
I am facing problem with ParticleSystemQuad particle creation in cocos2dx v4. I am creating particle as
auto particle = ParticleSystemQuad :: create ( “CompToolPar.plist” );
particle-> setPosition (pos);
parent-> addChild (particle, 100 );

error log is like

cocos2d: unsupported image format!
Assert failed: CCParticleSystem: error init image with data
Assertion failed : (isOK), function initWithDictionary,

This Code is working fine & good in v3.17 , but crashing in v4. Can someone look into this & help me out.

I wil take a look tomorrow

Please check image format. In v4 tiff is not supported

i am creating particles with ParticleDesigner https://www.71squared.com/particledesigner .
i am using .png as a texture image of particle. i am not using .tiff. i have checked the plist also, it includes .png format.

did you find anything?

No yet, I can’t export the file since the ParticleDesigner need a license.

sampleParticle.zip (25.6 KB)

You can try this for sample. i am using this particle. image which is use in this particle is .png format. no clue where i am getting it wrong.

It will works well if you did use the png specify in textureFileName. If png is missing then raw data in textureImageData will be used, which is a tiff format, thus cause v4 assert failed due to the unsupported tiff format.
So you can remove the key textureImageData and corresponding value in the plist and make sure the png in textureFileName dose exist.

1 Like

this might be the solution may b my png was not existing will try this. thanks for help. :+1:

my png dose exist, but same error. though removing textureImageData worked. Its strange it was using textureImageData even if png was available.
solution is removing textureImageData , worked for me. Thanks :slightly_smiling_face: :+1:

@coulsonwang
I got some issue relating to the TextureCube.
This texture is vanished after the phone returns to the foreground on Android. I found out that there is relevant callback inside TextureCube constructor. This callback only creates new gl texture buffer with

glGenTextures(1, &_textureInfo.texture)

And sets its parameters, but who should pass the actual texture data to this new created texture buffer? If to look further, the Texture2DGL::Texture2DGL(…) sets callback only on EVENT_RENDERER_RECREATED. And in that case the textures data, as I properly understand should be recovered inside

VolatileTextureMgr::reloadAllTextures()

Besides It looks like memory leacke, since the previous gl texture was not removed before.
I commented TextureCube to-foreground callback and tested without it - and all works well.
I believe that it should be changed callback for TextureCube on EVENT_RENDERER_RECREATED - could you confirm it?


After that I decided to switch off CC_ENABLE_CACHE_TEXTURE_DATA, since it wasted many memory, but I encountered with build error. There is cocos2d::VolatileTextureMgr::reloadAllTextures(); calling inside

JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)

which is not embraced with checking of CC_ENABLE_CACHE_TEXTURE_DATA macros. It leads to the link error. Could you fix it please.


And one more thing. There is RenderTexture class which set two callbacks - one for foreground and one for background. As pointed in code comments these callbacks are needed to save/restore texture in the corresponding events. I really could not understand where is restore code, since cocos2d::VolatileTextureMgr::reloadAllTextures() is hit only while EVENT_RENDERER_RECREATED. Are these callbacks are really needed. Please fix me if I wrong.

What’s the timeline of next release?

2 Likes

@zhangxm
@coulsonwang

Can you comment please above issue’s, which I have pointed?
I mostly bother about TextureCube problem and embracing of the VolatileTextureMgr::reloadAllTextures() with CC_ENABLE_CACHE_TEXTURE_DATA macros.

It looks like RenderTexture works properly.
Thanks in advance.

Is iOS13 the minimum iOS supported?

Come to think of it I’ve never tested on less than 13.

i have a project cocos2dx v3.9, it is possible to upgrade to v4 or better i create new project?

There is an upgrade guide

You can support both v3 and v4 with the same code. I have a relatively large project that is compatible with v3.17 and v4, with minor version-specific code in it.

The biggest issue would be any custom shaders, and it’s more than likely you would need two sets of those shaders, one for v3, and another for v4.

The game project CMakeLists.txt needs to be modified so it can be used for both versions as well.

1 Like

still can i use android.mk for configuration?

1 Like

Yes this is great advice. I have a project that is v4 on iOS and v3.17 on all other platforms.

1 Like