I want to make 100 buttons with same image.
Is there any optimize way to do this?
bn_B = Button::create("common/bn_chart_3.png","common/bn_chart_3.png");
bn_B->setPosition(Vec2(bn_A->getPositionX() + bn_A->getBoundingBox().size.width + paddingH, bn_A->getPositionY()));
this->addChild(bn_B, 5);
bn_C = Button::create("common/bn_chart_3.png","common/bn_chart_3.png");
bn_C->setPosition(Vec2(bn_B->getPositionX() + bn_B->getBoundingBox().size.width + paddingH, bn_A->getPositionY()));
this->addChild(bn_C, 5);
bn_A->addClickEventListener(CC_CALLBACK_1(LetterSelectionScreen::bn_letter_tapped, this));
bn_B->addClickEventListener(CC_CALLBACK_1(LetterSelectionScreen::bn_letter_tapped, this));
bn_C->addClickEventListener(CC_CALLBACK_1(LetterSelectionScreen::bn_letter_tapped, this));
So,Instead of writing it 100 times,What should I have to write for optimization.
I am using Cocos2d-X 3.8.
Anyone has any idea about it please share it.