diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index 57d5618a78..09280e9b63 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -1612,6 +1612,14 @@ std::string LabelBMFontBounds::subtitle() const } void LabelBMFontBounds::draw() +{ + CustomCommand *cmd = CustomCommand::getCommandPool().generateCommand(); + cmd->init(0, _vertexZ); + cmd->func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(cmd); +} + +void LabelBMFontBounds::onDraw() { auto labelSize = label1->getContentSize(); auto origin = Director::getInstance()->getWinSize(); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h index c532bef477..11c9934f93 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h @@ -376,6 +376,8 @@ public: virtual void draw(); virtual std::string title() const override; virtual std::string subtitle() const override; +protected: + void onDraw(); private: LabelBMFont *label1; };