From 676e40671734ab1212affe9d9ed76fd89f11f97f Mon Sep 17 00:00:00 2001 From: km7 dev <100500023+Kingminer7@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:06:13 +0000 Subject: [PATCH] Update popup tutorial to use initAnchored and m_mainLayer (#50) * Update popup tutorial to use initAnchored and m_mainLayer * use addchildatposition --------- Co-authored-by: mat <26722564+matcool@users.noreply.github.com> --- tutorials/popup.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tutorials/popup.md b/tutorials/popup.md index ee806cd..eb19ce5 100644 --- a/tutorials/popup.md +++ b/tutorials/popup.md @@ -39,15 +39,12 @@ However, what if you want to make a popup that's more complex? For example, some class MyPopup : public geode::Popup { protected: bool setup(std::string const& value) override { - auto winSize = CCDirector::sharedDirector()->getWinSize(); - // convenience function provided by Popup // for adding/setting a title to the popup this->setTitle("Hi mom!"); auto label = CCLabelBMFont::create(value.c_str(), "bigFont.fnt"); - label->setPosition(winSize / 2); - this->addChild(label); + m_mainLayer->addChildAtPosition(label, Anchor::Center); return true; } @@ -55,7 +52,7 @@ protected: public: static MyPopup* create(std::string const& text) { auto ret = new MyPopup(); - if (ret->init(240.f, 160.f, text)) { + if (ret->initAnchored(240.f, 160.f, text)) { ret->autorelease(); return ret; }