//
// LevelAreaLayer::init from 0x1002778e0 to 0x10027867b (3483 bytes)
//
// 3 xrefs:
// > LevelAreaLayer::scene @ 0x1002777c3
// > LevelAreaLayer::create @ 0x1002778a0
// > ??> @ 0x1008ef7d8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool __fastcall LevelAreaLayer::init(LevelAreaLayer *a1)
{
bool result; // al
void *v3; // rdi
cocos2d::CCArray *v4; // rax
cocos2d::CCTextureCache *v5; // rax
cocos2d::CCSpriteFrameCache *v6; // rax
cocos2d::CCSprite *v7; // rax
CCMenuItemSpriteExtra *v8; // r14
int v9; // edx
int v10; // ecx
int v11; // r8d
int v12; // r9d
__int64 v13; // r15
cocos2d::CCDirector *v14; // rax
cocos2d::CCDirector *v15; // rax
double v16; // xmm0_8
GameManager *v17; // rax
const char *BGTexture; // rax
cocos2d::CCSprite *v19; // r14
cocos2d::CCTexture2D *v20; // rax
cocos2d::CCLayerGradient *v21; // r14
cocos2d::CCFadeTo *v22; // rax
unsigned int v23; // r15d
cocos2d::CCFadeTo *v24; // rax
unsigned int v25; // eax
int v26; // ecx
int v27; // r8d
int v28; // r9d
cocos2d::CCActionInterval *v29; // rax
cocos2d::CCRepeatForever *v30; // rax
cocos2d::CCSprite *v31; // rax
cocos2d::CCSprite *m_towerSprite; // r14
cocos2d::CCSprite *v33; // r14
CCMenuItemSpriteExtra *v34; // r15
int v35; // edx
int v36; // ecx
int v37; // r8d
int v38; // r9d
const cocos2d::CCPoint *v39; // r12
__int64 v40; // rax
__int64 v41; // r13
cocos2d::CCSprite *v42; // r14
cocos2d::CCSprite *v43; // r14
LevelAreaLayer *v44; // r13
cocos2d::CCSprite *v45; // r14
cocos2d::CCSprite *v46; // rbx
__int64 v47; // r14
cocos2d::CCMoveBy *v48; // rax
cocos2d::CCMoveBy *v49; // rax
unsigned int v50; // eax
int v51; // ecx
int v52; // r8d
int v53; // r9d
cocos2d::CCActionInterval *v54; // rax
cocos2d::CCRepeatForever *v55; // rax
__int64 v56; // r14
cocos2d::CCNode *v57; // r14
float v58; // xmm1_4
GameManager *v59; // rax
unsigned int v60; // ebx
unsigned int v61; // eax
int v62; // ecx
int v63; // r8d
int v64; // r9d
cocos2d::CCAction *v65; // rax
__int128 v66; // [rsp+10h] [rbp-B0h] BYREF
char v67; // [rsp+20h] [rbp-A0h] BYREF
char v68[15]; // [rsp+21h] [rbp-9Fh] BYREF
void *__p; // [rsp+30h] [rbp-90h]
std::string __str; // [rsp+38h] [rbp-88h] BYREF
float v71; // [rsp+54h] [rbp-6Ch]
int v72; // [rsp+58h] [rbp-68h] BYREF
LevelAreaLayer *v73; // [rsp+60h] [rbp-60h]
_BYTE v74[8]; // [rsp+68h] [rbp-58h] BYREF
float v75; // [rsp+70h] [rbp-50h] BYREF
float v76; // [rsp+74h] [rbp-4Ch]
cocos2d::CCPoint v77[2]; // [rsp+78h] [rbp-48h] BYREF
void *v78; // [rsp+88h] [rbp-38h]
bool v79; // [rsp+97h] [rbp-29h]
double v80; // 0:xmm0_8.8
cocos2d::CCPoint v81; // 0:xmm5_8.8
cocos2d::CCPoint v82; // 0:xmm5_8.8
cocos2d::CCPoint v83; // 0:xmm5_8.8
cocos2d::CCPoint v84; // 0:xmm5_8.8
cocos2d::CCPoint v85; // 0:xmm5_8.8
cocos2d::CCPoint v86; // 0:xmm5_8.8
result = cocos2d::CCLayer::init(a1);
if ( result )
{
v79 = result;
v67 = 22;
strcpy(v68, "tower01.mp3");
v3 = GameManager::sharedState();
GameManager::fadeInMusic(v3, &v67);
if ( (v67 & 1) != 0 )
{
v3 = __p;
operator delete(__p);
}
v4 = (cocos2d::CCArray *)sub_10071F9E0(v3, &v67);
a1->m_godRays = v4;
cocos2d::CCObject::retain(v4);
v5 = cocos2d::CCTextureCache::sharedTextureCache();
cocos2d::CCTextureCache::addImage(v5, "TowerSheet.png", 0);
v6 = cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache();
cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile_2(v6, "TowerSheet.plist");
((void (__fastcall *)(LevelAreaLayer *, __int64))a1->setKeypadEnabled)(a1, 1);
((void (__fastcall *)(LevelAreaLayer *, __int64))a1->setKeyboardEnabled)(a1, 1);
cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)&v75);
v7 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
v8 = CCMenuItemSpriteExtra::create(
v7,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)LevelAreaLayer::onBack);
CCMenuItemSpriteExtra::setSizeMult(v8, 1.6);
v13 = sub_100792C50((_DWORD)v8, 0, v9, v10, v11, v12);
((void (__fastcall *)(LevelAreaLayer *, __int64, __int64))a1->addChild_0)(a1, v13, 1);
v14 = cocos2d::CCDirector::sharedDirector();
*(float *)&v73 = sub_100484D90(v14) + 24.0;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = sub_100484D70(v15);
sub_10028CBE0(v77, *(float *)&v73, *(float *)&v16 + -23.0);
(*(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v13 + 184LL))(v13, v77);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v8);
v17 = GameManager::sharedState();
BGTexture = GameManager::getBGTexture(v17, 23);
v19 = cocos2d::CCSprite::create_1(BGTexture);
v66 = xmmword_100815E00;
v20 = (cocos2d::CCTexture2D *)((__int64 (__fastcall *)(cocos2d::CCSprite *))v19->getTexture)(v19);
cocos2d::CCTexture2D::setTexParameters(v20, (cocos2d::ccTexParams *)&v66);
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v19, 4294967293LL);
sub_10028CBE0(v77, 0.0, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v19->setAnchorPoint)(v19, v77);
((void (__fastcall *)(cocos2d::CCSprite *, float))v19->setScale)(v19, v75 / v19->m_obRect.size.width);
sub_10028CBE0(v77, 0.0, -50.0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v19->setPosition)(v19, v77);
BYTE2(v77[0].x) = -76;
LOWORD(v77[0].x) = 15360;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v19->setColor)(v19, v77);
v77[0].x = -4.13584e-25;
v72 = 16776960;
v21 = cocos2d::CCLayerGradient::create_1((const cocos2d::ccColor4B *)v77, (const cocos2d::ccColor4B *)&v72);
sub_10028CBE0(v77, 0.0, 1.0);
((void (__fastcall *)(cocos2d::CCLayerGradient *, cocos2d::CCPoint *))v21->setAnchorPoint)(v21, v77);
((void (__fastcall *)(cocos2d::CCLayerGradient *, __int64))v21->setBlendFunc)(v21, 0x100000302LL);
v21->m_bShouldPremultiply = 1;
((void (__fastcall *)(cocos2d::CCLayerGradient *, float))v21->setScaleY)(v21, 0.69999999);
((void (__fastcall *)(cocos2d::CCLayerGradient *))v21->updateColor)(v21);
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCLayerGradient *, __int64))a1->addChild_0)(a1, v21, 2);
v22 = cocos2d::CCFadeTo::create(3.0, 0xFFu);
v23 = (unsigned int)cocos2d::CCEaseInOut::create(v22, 2.0);
v24 = cocos2d::CCFadeTo::create(3.0, 0x96u);
v25 = (unsigned int)cocos2d::CCEaseInOut::create(v24, 2.0);
v29 = (cocos2d::CCActionInterval *)sub_1003B5760(v23, v25, 0, v26, v27, v28);
v30 = cocos2d::CCRepeatForever::create(v29);
cocos2d::CCNode::runAction(v21, v30);
v31 = cocos2d::CCSprite::createWithSpriteFrameName("theTower_01_001.png");
a1->m_towerSprite = v31;
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCSprite *, __int64))a1->addChild_0)(a1, v31, 1);
((void (__fastcall *)(cocos2d::CCSprite *, float))a1->m_towerSprite->setScale)(a1->m_towerSprite, 1.0);
m_towerSprite = a1->m_towerSprite;
sub_10028CBE0(v77, v75 * 0.5, v76 * 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))m_towerSprite->setPosition)(m_towerSprite, v77);
v33 = cocos2d::CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, float))v33->setScaleX)(v33, 2.0);
((void (__fastcall *)(cocos2d::CCSprite *, float))v33->setScaleY)(v33, 2.2);
v34 = CCMenuItemSpriteExtra::create(
v33,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)LevelAreaLayer::onClickDoor);
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)20;
strcpy(__str.__r_.__value_.__s.__data_, "door02.ogg");
std::string::operator=((std::string *)&v34->m_activateSound, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v39 = (const cocos2d::CCPoint *)sub_100792C50((_DWORD)v34, 0, v35, v36, v37, v38);
((void (__fastcall *)(LevelAreaLayer *, const cocos2d::CCPoint *, __int64))a1->addChild_0)(a1, v39, 10);
v40 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a1->m_towerSprite->getPosition)(a1->m_towerSprite);
v73 = a1;
v41 = v40;
sub_10028CBE0(v74, 0.0, -75.0);
sub_10028CCE0(&v72, v41);
*(cocos2d::CCPoint *)&v80 = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v77, v39);
((void (__fastcall *)(CCMenuItemSpriteExtra *, cocos2d::CCPoint *, double))v34->setPosition)(v34, v77, v80);
((void (__fastcall *)(cocos2d::CCSprite *, _QWORD))v33->setOpacity)(v33, 0);
v42 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, void *))v42->setColor)(v42, &unk_1008188B8);
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCSprite *, __int64))v73->addChild_0)(v73, v42, 0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::CCSprite *, float))v42->setScaleX)(v42, v76 / v42->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, float))v42->setScaleY)(v42, 3.0);
((void (__fastcall *)(cocos2d::CCSprite *, float))v42->setRotation)(v42, 90.0);
sub_10028CBE0(v77, 0.0, v76 * 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v42->setPosition)(v42, v77);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v42->setOpacity)(v42, 125);
BYTE2(v77[0].x) = 50;
LOWORD(v77[0].x) = 0;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v42->setColor)(v42, v77);
v43 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, void *))v43->setColor)(v43, &unk_1008188B8);
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCSprite *, __int64))v73->addChild_0)(v73, v43, 0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::CCSprite *, float))v43->setScaleX)(v43, v76 / v43->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, float))v43->setScaleY)(v43, 3.0);
((void (__fastcall *)(cocos2d::CCSprite *, float))v43->setRotation)(v43, 90.0);
sub_10028CBE0(v77, v75, v76 * 0.5);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v43->setPosition)(v43, v77);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v43->setOpacity)(v43, 125);
BYTE2(v77[0].x) = 50;
LOWORD(v77[0].x) = 0;
v44 = v73;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v43->setColor)(v43, v77);
v45 = cocos2d::CCSprite::createWithSpriteFrameName("godray01_001.png");
((void (__fastcall *)(cocos2d::CCSprite *, void *))v45->setColor)(v45, &unk_1008188B8);
((void (__fastcall *)(LevelAreaLayer *, cocos2d::CCSprite *, __int64))v44->addChild_0)(v44, v45, 0xFFFFFFFFLL);
((void (__fastcall *)(cocos2d::CCSprite *, float))v45->setScaleX)(v45, v75 / v45->m_obRect.size.width);
((void (__fastcall *)(cocos2d::CCSprite *, float))v45->setScaleY)(v45, 1.0);
sub_10028CBE0(v77, v75 * 0.5, 0.0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v45->setPosition)(v45, v77);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))v45->setOpacity)(v45, 125);
BYTE2(v77[0].x) = 50;
LOWORD(v77[0].x) = 0;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v45->setColor)(v45, v77);
v46 = v44->m_towerSprite;
v47 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))v46->getPosition)(v46);
sub_10028CBE0(&v72, 0.0, -2.0);
sub_10028CCE0(v77, v47);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCPoint *))v46->setPosition)(v46, v77);
sub_10028CBE0(v77, 0.0, 4.0);
v48 = cocos2d::CCMoveBy::create(2.0, v77);
LODWORD(v46) = (unsigned int)cocos2d::CCEaseInOut::create(v48, 2.0);
sub_10028CBE0(v77, 0.0, -4.0);
v49 = cocos2d::CCMoveBy::create(2.0, v77);
v50 = (unsigned int)cocos2d::CCEaseInOut::create(v49, 2.0);
v54 = (cocos2d::CCActionInterval *)sub_1003B5760((_DWORD)v46, v50, 0, v51, v52, v53);
v55 = cocos2d::CCRepeatForever::create(v54);
cocos2d::CCNode::runAction(v44->m_towerSprite, v55);
sub_10028CBE0(&v72, v75 * 0.5, (float)(v76 * 0.5) + 13.0);
sub_10028CBE0(v74, 0.0, 0.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 50.0, 0.0, 125.0, 5.0, 4.0, v81);
sub_10028CBE0(v74, 0.0, 10.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 25.0, 125.0, 0.0, 3.0, 2.5, v82);
sub_10028CBE0(v74, 0.0, 20.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 125.0, 25.0, 125.0, 4.0, 3.0, v83);
sub_10028CBE0(v74, 0.0, -20.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 75.0, 0.0, 100.0, 6.0, 2.5, v84);
sub_10028CBE0(v74, 0.0, -10.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 0.0, 100.0, 25.0, 5.0, 3.5, v85);
sub_10028CBE0(v74, 0.0, 10.0);
sub_10028CCE0(v77, &v72);
LevelAreaLayer::addGodRay(v44, 0.0, 75.0, 25.0, 4.5, 2.5, v86);
v78 = operator new(0xA0u);
v77[0] = (cocos2d::CCPoint)161LL;
v77[1] = (cocos2d::CCPoint)159LL;
strcpy(
(char *)v78,
"60a-1a8a2a6a90a90a0a2a45a70a0a0a0a0a0a0a1a0a0a0a1a0a0.886275a0a0a0a0a0.7a1a0a0a0a1a0a0.552941a0a0a0a0a0.7a2a0a2a0a"
"0a0a0a0a0a0a0a2a1a0a0a0a0a0a0a0a0a0a0a0a0a0a0");
v56 = GameToolbox::particleFromString(v77, 0, 0);
if ( (LOBYTE(v77[0].x) & 1) != 0 )
operator delete(v78);
((void (__fastcall *)(LevelAreaLayer *, __int64, _QWORD))v44->addChild_0)(v44, v56, 0);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 344LL))(v56, 30.0);
sub_10028CBE0(v77, 100.0, 40.0);
(*(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v56 + 944LL))(v56, v77);
sub_10028CBE0(v74, -100.0, 60.0);
sub_10028CCE0(v77, &v72);
(*(void (__fastcall **)(__int64, cocos2d::CCPoint *))(*(_QWORD *)v56 + 184LL))(v56, v77);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
(*(void (__fastcall **)(__int64, float))(*(_QWORD *)v56 + 40LL))(v56, 0.2);
v57 = v44->m_towerSprite;
v71 = (float)(*(float *)((__int64 (__fastcall *)(cocos2d::CCNode *))v57->getContentSize)(v57) * 0.5) + 35.0;
v58 = (float)(0.5
* *(float *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))v44->m_towerSprite->getContentSize)(v44->m_towerSprite)
+ 4))
+ -69.5;
sub_10028CBE0(v77, v71, v58);
LevelAreaLayer::addTorch(v57, (cocos2d::CCPoint)1053609165LL, (int)v77, v58, 1, 6, 0, nullptr);
v59 = GameManager::sharedState();
if ( !GameManager::getUGV(v59, "29") )
{
v44->m_enteringTower = 1;
v60 = (unsigned int)cocos2d::CCDelayTime::create(1.2);
v61 = (unsigned int)cocos2d::CCCallFunc::create(
v44,
(cocos2d::SEL_CallFunc)(unsigned __int64)LevelAreaLayer::showDialog);
v65 = (cocos2d::CCAction *)sub_1003B5760(v60, v61, 0, v62, v63, v64);
cocos2d::CCNode::runAction(v44, v65);
}
return v79;
}
return result;
}