44BadgeMenu* BadgeMenu::scene (CCArray* array) {
55 auto popup = new BadgeMenu (array);
66
7- if (popup && popup->initAnchored ( 300 . 0f , 210 . 0f )) {
7+ if (popup && popup->init ( )) {
88 popup->autorelease ();
99 popup->setZOrder (1000 );
1010 popup->show ();
@@ -17,7 +17,9 @@ BadgeMenu* BadgeMenu::scene(CCArray* array) {
1717
1818BadgeMenu::BadgeMenu (CCArray* data) : m_data(data) {}
1919
20- bool BadgeMenu::setup () {
20+ bool BadgeMenu::init () {
21+ if (!geode::Popup::init (300 .0f , 210 .0f )) return false ;
22+
2123 auto winSize = cocos2d::CCDirector ::sharedDirector ()->getWinSize ();
2224 auto director = cocos2d::CCDirector::sharedDirector ();
2325
@@ -28,7 +30,15 @@ bool BadgeMenu::setup() {
2830
2931 CCObject* obj;
3032 CCArray* cell = CCArray::create ();
31- CCARRAY_FOREACH (m_data, obj) {
33+ // CCARRAY_FOREACH(m_data, obj) {
34+ // cell->addObject(obj);
35+ // if (cell->count() == badges_max) {
36+ // cells.push_back(BadgeMenuCell::create(cell, { 300, 210 }));
37+ // cell = CCArray::create();
38+ // }
39+ // }
40+ for (CCObject* obj : CCArrayExt<CCObject*>(m_data)) {
41+ if (!obj) continue ;
3242 cell->addObject (obj);
3343 if (cell->count () == badges_max) {
3444 cells.push_back (BadgeMenuCell::create (cell, { 300 , 210 }));
0 commit comments