Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions src/EndLevelLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ using namespace geode::node_ids;
leaderboardButton->setID("practice-retry-button");
}

int currentCoin = 1;
int currentCoin = 1; // this is so the first id is coin-1
auto mainLayerChildren = CCArrayExt<CCNode*>(m_mainLayer->getChildren());
std::vector<CCPoint> coinPos;
for (auto child : CCArrayExt<CCNode*>(m_mainLayer->getChildren())) {
for (auto child : mainLayerChildren) {
for (auto framename : {
"secretCoin_b_01_001.png",
"secretCoin_2_b_01_001.png"
Expand All @@ -128,22 +129,37 @@ using namespace geode::node_ids;
}
}

for (auto child : CCArrayExt<CCNode*>(m_mainLayer->getChildren())) {
for (int i = 1; i < currentCoin; i++) {
if (child->getID().empty() && child->getPosition() == coinPos[i - 1]) {
child->setID(fmt::format("coin-{}-sprite", i));
if (currentCoin > 1) {
int matchedCoins = 1;
// fun fact the controller icon is always set before this one
for (auto child : CCArrayExt<CCNode*>(m_coinsToAnimate)) {
for (int i = 1; i < currentCoin; i++) {
if (child->getID().empty() && child->getPosition() == coinPos[i-1]) {
child->setID(fmt::format("coin-{}-sprite", i));
matchedCoins++;
break;
}
}
}
}

for (auto child : CCArrayExt<CCNode*>(m_coinsToAnimate)) {
for (int i = 1; i < currentCoin; i++) {
if (child->getID().empty() && child->getPosition() == coinPos[i - 1]) {
child->setID(fmt::format("coin-{}-sprite", i));
}
// idx should not be kept the same if they are not matching
if (matchedCoins < currentCoin) {
// idx is after all the other ids, controller icons are always set after these for some reason?
for (int fl = idx; fl < mainLayerChildren.size(); fl++) {
if (matchedCoins >= currentCoin) {
break; // escape if finished
};
auto child = mainLayerChildren[fl];
for (int i = 1; i < currentCoin; i++) {
if (child->getID().empty() && child->getPosition() == coinPos[i-1]) {
child->setID(fmt::format("coin-{}-sprite", i));
idx = fl+1;
matchedCoins++;
break;
};
};
};
}
}

if (PlatformToolbox::isControllerConnected()) {
setIDs(
m_mainLayer,
Expand All @@ -153,7 +169,6 @@ using namespace geode::node_ids;
);
idx += 2;
}

// original code by alphalaneous, adapted to node IDs by raydeeux
std::reverse(nodesToMove.begin(), nodesToMove.end());

Expand Down