-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f6de20
commit 76d339b
Showing
8 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "CountdownLayer.hpp" | ||
|
||
bool CountdownLayer::init() | ||
{ | ||
if (!CCLayer::init()) | ||
return false; | ||
|
||
this->setKeypadEnabled(true); | ||
this->schedule(schedule_selector(CountdownLayer::onDecrement), 1); | ||
|
||
label = CCLabelBMFont::create(fmt::format("{}", count).c_str(), "goldFont.fnt"); | ||
label->setPosition(CCDirector::get()->getWinSize() / 2); | ||
|
||
applyAnimation(); | ||
|
||
this->addChild(label); | ||
return true; | ||
} | ||
|
||
void CountdownLayer::onDecrement(float) | ||
{ | ||
count--; | ||
label->setString(fmt::format("{}", count).c_str()); | ||
applyAnimation(); | ||
|
||
if (count == 0) | ||
{ | ||
onCountReachedZero(); | ||
} | ||
} | ||
|
||
void CountdownLayer::onCountReachedZero() | ||
{ | ||
PlayLayer::get()->resume(); | ||
|
||
this->removeFromParent(); | ||
} | ||
|
||
void CountdownLayer::applyAnimation() | ||
{ | ||
label->setScale(2.2f); | ||
label->runAction(CCEaseElasticOut::create(CCScaleTo::create(0.5f, 1.5f))); | ||
|
||
label->setOpacity(0); | ||
label->runAction(CCEaseInOut::create(CCFadeTo::create(0.5f, 255), 2)); | ||
} | ||
|
||
void CountdownLayer::keyBackClicked() | ||
{ | ||
PlayLayer::get()->resume(); | ||
PlayLayer::get()->pauseGame(false); | ||
|
||
this->removeFromParent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <Geode/Geode.hpp> | ||
#include "../../Client/Client.h" | ||
|
||
using namespace geode::prelude; | ||
|
||
class CountdownLayer : public CCLayer | ||
{ | ||
public: | ||
CCLabelBMFont* label; | ||
int count = 3; | ||
|
||
void onDecrement(float); | ||
void applyAnimation(); | ||
|
||
virtual bool init(); | ||
virtual void onCountReachedZero(); | ||
virtual void keyBackClicked(); | ||
|
||
CREATE_FUNC(CountdownLayer); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <Geode/Geode.hpp> | ||
#include <Geode/modify/PauseLayer.hpp> | ||
#include "../../Client/Client.h" | ||
#include "CountdownLayer.hpp" | ||
|
||
using namespace geode::prelude; | ||
|
||
class $modify (PauseLayer) | ||
{ | ||
void onResume(cocos2d::CCObject* sender) | ||
{ | ||
auto countdown = CountdownLayer::create(); | ||
CCScene::get()->addChild(countdown); | ||
|
||
CCTouchDispatcher::get()->unregisterForcePrio(this); | ||
this->removeFromParent(); | ||
} | ||
|
||
QOLMOD_MOD_ALL_HOOKS("pause-countdown") | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
#include "Utils.hpp" | ||
|
||
float roundUpToMultipleOf2(float num) { | ||
float roundUpToMultipleOf2(float num) | ||
{ | ||
float roundedNum = std::ceil(num / 2.0f) * 2.0f; | ||
return roundedNum; | ||
} | ||
|
||
float scaleFloat(float v, float min, float max) | ||
{ | ||
return (max - min) * v + min; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters