CSLoader works slow the first time

Hi!

My game loads a node at a certain point and I use this code:

image = (ImageNode*)CSLoader::createNode(outlineName);
image->setPosition(0, 0);
image->retain();
this->addChild(image);

The first time it loads it freezes for like 1sec, every next time (even if we load a different node with totally different sprites) there is no freeze and it works as it should.

Why is it so? Do I need to initialise the CSLoader somewhere to avoid this first 1sec delay?

Because it loads all sprites and other stuff from your scene. That includes loading textures for all stuff as well. But once these textures are loaded they’re in texture cache. So second time you load this scene it’s way faster, because it doesn’t need to load textures again. Try cleaning texture cache and you’ll see it’ll be the same each time.