-
Notifications
You must be signed in to change notification settings - Fork 18
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
TheSillyDoggo
committed
Oct 3, 2024
1 parent
91eb96a
commit 1295281
Showing
6 changed files
with
98 additions
and
14 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
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,61 @@ | ||
#include "RepeatableMenuItemSpriteExtra.hpp" | ||
|
||
void RepeatableMenuItemSpriteExtra::update(float dt) | ||
{ | ||
if (!m_bEnabled) | ||
{ | ||
m_bSelected = false; | ||
} | ||
|
||
if (!m_bSelected) | ||
{ | ||
t = 0; | ||
v = 0; | ||
d = 0; | ||
return; | ||
} | ||
|
||
t += dt; | ||
|
||
if (t > startDelay) | ||
{ | ||
v += dt; | ||
|
||
if (v > repeatTime - d) | ||
{ | ||
v -= repeatTime - d; | ||
|
||
d += repTimeInc; | ||
|
||
if (d > repeatTime - maxSpeed) | ||
d = repeatTime - maxSpeed; | ||
|
||
activate(); | ||
|
||
auto sequence = CCSequence::create(CCEaseBackOut::create(CCScaleBy::create(0.07f, 1.2f)), CCDelayTime::create(0.02f), CCScaleBy::create(0.1f, 1.0f / 1.2f), nullptr); | ||
|
||
this->runAction(sequence); | ||
} | ||
} | ||
} | ||
|
||
RepeatableMenuItemSpriteExtra* RepeatableMenuItemSpriteExtra::create(cocos2d::CCNode* sprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback) | ||
{ | ||
auto pRet = new RepeatableMenuItemSpriteExtra(); | ||
|
||
if (pRet && pRet->init(sprite, disabledSprite, target, callback)) | ||
{ | ||
pRet->scheduleUpdate(); | ||
|
||
pRet->autorelease(); | ||
return pRet; | ||
} | ||
|
||
CC_SAFE_DELETE(pRet); | ||
return nullptr; | ||
} | ||
|
||
RepeatableMenuItemSpriteExtra* RepeatableMenuItemSpriteExtra::create(cocos2d::CCNode* sprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback) | ||
{ | ||
return create(sprite, nullptr, target, callback); | ||
} |
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,22 @@ | ||
#pragma once | ||
|
||
#include <Geode/Geode.hpp> | ||
|
||
using namespace geode::prelude; | ||
|
||
class RepeatableMenuItemSpriteExtra : public CCMenuItemSpriteExtra | ||
{ | ||
public: | ||
float maxSpeed = 0.03f; | ||
float repTimeInc = 0.003f; | ||
float repeatTime = 0.15f; | ||
float startDelay = 0.4f; | ||
float t = 0; | ||
float v = 0; | ||
float d = 0; | ||
|
||
virtual void update(float dt); | ||
|
||
static RepeatableMenuItemSpriteExtra* create(cocos2d::CCNode* sprite, cocos2d::CCNode* disabledSprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback); | ||
static RepeatableMenuItemSpriteExtra* create(cocos2d::CCNode* sprite, cocos2d::CCObject* target, cocos2d::SEL_MenuHandler callback); | ||
}; |