mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -05:00
make top sprite offset settable in BasedButtonSprite
This commit is contained in:
parent
1e0a8c5e2f
commit
2825654361
2 changed files with 9 additions and 4 deletions
|
@ -148,6 +148,7 @@ namespace geode {
|
|||
int m_size;
|
||||
int m_color;
|
||||
cocos2d::CCNode* m_onTop = nullptr;
|
||||
cocos2d::CCPoint m_topOffset = CCPointZero;
|
||||
|
||||
bool init(cocos2d::CCNode* ontop, BaseType type, int size, int color);
|
||||
bool initWithSprite(
|
||||
|
@ -157,7 +158,6 @@ namespace geode {
|
|||
const char* sprName, float sprScale, BaseType type, int size, int color
|
||||
);
|
||||
|
||||
cocos2d::CCPoint getTopOffset() const;
|
||||
virtual cocos2d::CCSize getMaxTopSize() const;
|
||||
|
||||
virtual ~BasedButtonSprite();
|
||||
|
@ -180,6 +180,11 @@ namespace geode {
|
|||
cocos2d::CCNode* ontop, BaseType type, int size, int color
|
||||
);
|
||||
|
||||
/**
|
||||
* Set an offset to the top sprite
|
||||
*/
|
||||
void setTopOffset(CCPoint const& offset);
|
||||
|
||||
cocos2d::CCNode* getTopNode() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ bool BasedButtonSprite::init(CCNode* ontop, BaseType type, int size, int color)
|
|||
|
||||
if (ontop) {
|
||||
m_onTop = ontop;
|
||||
m_onTop->setPosition(this->getContentSize() / 2 + this->getTopOffset());
|
||||
m_onTop->setPosition(this->getContentSize() / 2 + m_topOffset);
|
||||
limitNodeSize(m_onTop, this->getMaxTopSize(), m_onTop->getScale(), .1f);
|
||||
this->addChild(m_onTop);
|
||||
}
|
||||
|
@ -202,8 +202,8 @@ CCSize BasedButtonSprite::getMaxTopSize() const {
|
|||
return m_obContentSize - CCSize(18.f, 18.f);
|
||||
}
|
||||
|
||||
CCPoint BasedButtonSprite::getTopOffset() const {
|
||||
return { 0, 0 };
|
||||
void BasedButtonSprite::setTopOffset(CCPoint const& offset) {
|
||||
m_topOffset = offset;
|
||||
}
|
||||
|
||||
bool BasedButtonSprite::initWithSprite(
|
||||
|
|
Loading…
Reference in a new issue