Search code examples
c++cocos2d-iphonecocos2d-xcocos2d-x-3.0particles

Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"


I am trying to load particle effects (in .plist format) in my Cocos2d-x game code, and I am facing the warning: "libpng warning: iCCP: known incorrect sRGB profile", as mentioned in the question. I have done some research on my end, and the other StackOverflow users who asked similar questions had this issue while loading .png files.

However, I am facing the same issue while initializing .plist files instead. Any insight on how to remove this warning would be helpful. Kindly note that I am not facing any issue with loading the .plist file as such, but the warnings are polluting my log streams.

Sample code:

ParticleSystem* testStar = testNode->getChildByName<ParticleSystem*>("star");
testStar->initWithFile(filePath + "/" + "test.plist"); //valid filePath
testStar->setVisible(true); 

Also, to confirm that this isn't an issue with the .plist file itself, I tried loading the file manually on my UI editor tool, and that seemed to load it without any issues.

I am ready to provide more details on my environment if necessary. I tried doing the above in a blank project as well, and I was able to reproduce the same warning.

Cocos2d-x version: cocos2d-x-3.14.1


Solution

  • I was able to solve this by using a sub-class of ParticleSystem instead of ParticleSystem itself. The sub-class I used is ParticleSystemQuad. Additionally, I realized that the initWithFile API was being called multiple times in my code, due to Cocos2D update schedulers. That may have been a cause for this warning.

    To fix this warning, I created a fresh variable/system, and assigned a parent to it, while setting the position of the new variable to that of a well-known (desired position) node.

    /* Getting the desired particleEffect position */    
    const Vec2& desiredPos = testNode->getChildByName("blablablah")->getPosition();
    std::string filePath = "/"; //assign a directory for the .plist
    
    // Avoid exponentiation
    if (!testNode->getChildByName("sampleParticle")) {
        auto p1 = ParticleSystemQuad::create(filePath + "/" + "test.plist");
        p1->setPosition(desiredPos);
        p1->resetSystem();
        p1->setName("sampleParticle");
        p1->setVisible(true);
        testNode->addChild(p1);
    }