From 6ce6bd859618a3c4fafd93bdb118924d16dfaa8d Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Sat, 17 Feb 2024 00:26:11 +0300 Subject: [PATCH] fix the coin --- src/EndLevelLayer.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/EndLevelLayer.cpp b/src/EndLevelLayer.cpp index dd4a572..b2b64f2 100644 --- a/src/EndLevelLayer.cpp +++ b/src/EndLevelLayer.cpp @@ -126,21 +126,29 @@ inline CCNode* getChildBySpriteFrameName(CCNode* parent, const char* name) { } int currentCoin = 1; + std::vector coinPos; for (auto child : CCArrayExt(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(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,