Skip to content

Commit

Permalink
fix the coin
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Feb 16, 2024
1 parent a587a5f commit 6ce6bd8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/EndLevelLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,29 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) {
}

int currentCoin = 1;
std::vector<CCPoint> coinPos;
for (auto child : CCArrayExt<CCNode*>(m_mainLayer->getChildren())) {
for (auto framename : {
"secretCoin_b_01_001.png",
"secretCoin_2_b_01_001.png",
"secretCoinUI_001.png",
"secretCoinUI2_001.png"
"secretCoin_2_b_01_001.png"
}) {
if (::isSpriteFrameName(child, framename)) {
child->setID(fmt::format("coin-{}-sprite", currentCoin));
child->setID(fmt::format("coin-{}-background", currentCoin));
coinPos.push_back(child->getPosition());
currentCoin += 1;
idx += 1;
}
}
}

for (auto child : CCArrayExt<CCNode*>(m_mainLayer->getChildren())) {
for (int i = 1; i < currentCoin; i++) {
if (child->getPosition() == coinPos[i - 1]) {
child->setID(fmt::format("coin-{}-sprite", i));
}
}
}

if (PlatformToolbox::isControllerConnected()) {
setIDs(
m_mainLayer,
Expand Down

0 comments on commit 6ce6bd8

Please sign in to comment.