@@ -33,7 +33,16 @@ bool BaseCustomAlertLayer::createBasics(const BaseCustomAlertData& alertData)
3333 m_buttonMenu->setID (" button-menu" );
3434 m_mainLayer->addChild (m_buttonMenu, 10 );
3535
36- closeBtn = createButton (" GJ_closeBtn_001.png" , { -((alertSize.x ) / 2 .f ) + 9 .5f , (alertSize.y / 2 .f ) - 10 .f }, alertData.onClose , -1 , alertData.closeBtnScale );
36+ auto buttonSprite = CCSprite::createWithSpriteFrameName (" GJ_closeBtn_001.png" );
37+ buttonSprite->setScale (alertData.closeBtnScale );
38+ closeBtn = CCMenuItemSpriteExtra::create (
39+ buttonSprite,
40+ this ,
41+ alertData.onClose
42+ );
43+ closeBtn->setPosition ({ -((alertSize.x ) / 2 .f ) + 9 .5f , (alertSize.y / 2 .f ) - 10 .f });
44+ closeBtn->setSizeMult (1 .2f );
45+ m_buttonMenu->addChild (closeBtn);
3746
3847 return true ;
3948}
@@ -52,24 +61,6 @@ void BaseCustomAlertLayer::createTitle(std::string text, float separatorScale, f
5261 m_buttonMenu->addChild (separator);
5362}
5463
55- CCMenuItemSpriteExtra* BaseCustomAlertLayer::createButton (const char * texture, CCPoint position, SEL_MenuHandler callback, int tag, float textureScale, float sizeMult)
56- {
57- auto buttonSprite = CCSprite::createWithSpriteFrameName (texture);
58- buttonSprite->setScale (textureScale);
59- auto button = CCMenuItemSpriteExtra::create (
60- buttonSprite,
61- this ,
62- callback
63- );
64- button->setPosition (position);
65- button->setSizeMult (sizeMult);
66- if (tag != -1 )
67- button->setTag (tag);
68- m_buttonMenu->addChild (button);
69-
70- return button;
71- }
72-
7364// overriden because clicking space crashes the game
7465void BaseCustomAlertLayer::keyDown (enumKeyCodes key)
7566{
@@ -81,3 +72,8 @@ void BaseCustomAlertLayer::keyBackClicked()
8172{
8273 onClose (nullptr );
8374}
75+
76+ BaseCustomAlertLayer::~BaseCustomAlertLayer ()
77+ {
78+ CCDirector::sharedDirector ()->getTouchDispatcher ()->unregisterForcePrio (this );
79+ }
0 commit comments