Drop FPS on WP8 with spirte and label

Hi!

I have a problem when i’m try add a Sprite and a Label in a parent node. I was trying test on android and ios it works perfectly (fps: 60), but i test on WP8 (Lumia 730). FPS is 4fps
Here is my code

bool HelloWorld::init()
{
	// Init
    if ( !Layer::init() )    return false;
for (int i = 0; i<100; i++)
	{
		// Parent Node
		Node *pNode = Node::create();
		pNode->setPosition(rand()%800, rand()%800);
		this->addChild(pNode);

		// Add Label
		Label *pLabel = Label::createWithTTF("My Text", "fonts/Marker Felt.ttf", 30);
		pLabel->setColor(Color3B::RED);
		pNode->addChild(pLabel, 0);

		// Add Sprite
		Sprite *pSprite = Sprite::create("CloseNormal.png");
		pNode->addChild(pSprite, 1);
	}

	return true;
}

When i try

bool HelloWorld::init()
    {
    	// Init
        if ( !Layer::init() )    return false;
    for (int i = 0; i<100; i++)
    	{
    		// Parent Node
    		Node *pNode = Node::create();
    		pNode->setPosition(rand()%800, rand()%800);
    		this->addChild(pNode);
    
    		// Add Label
    		Label *pLabel = Label::createWithTTF("My Text", "fonts/Marker Felt.ttf", 30);
    		pLabel->setColor(Color3B::RED);
    		this->addChild(pLabel, 0);
    
    		// Add Sprite
    		Sprite *pSprite = Sprite::create("CloseNormal.png");
    		this->addChild(pSprite, 1);
    	}
    
    	return true;
    }

It works well. FPS is 60 on Lumia 730
Please explain and give me solution. Thanks!

Nobody :frowning: ?

This is due to auto batching. In the former snippet, there is no batching because each Label and Sprite is arranged as Label-Sprite-Label-Sprite… as you use a container for a pair. The other case each Label is at 0 zOrder, each Sprite is at 1 zOrder => auto batching => 2 draw calls => boost performance.

Thing goes bad in WP8 if draw calls greater than 5 or 10 draw calls. Better performance in Android and iOs devices.