mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -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_size;
|
||||||
int m_color;
|
int m_color;
|
||||||
cocos2d::CCNode* m_onTop = nullptr;
|
cocos2d::CCNode* m_onTop = nullptr;
|
||||||
|
cocos2d::CCPoint m_topOffset = CCPointZero;
|
||||||
|
|
||||||
bool init(cocos2d::CCNode* ontop, BaseType type, int size, int color);
|
bool init(cocos2d::CCNode* ontop, BaseType type, int size, int color);
|
||||||
bool initWithSprite(
|
bool initWithSprite(
|
||||||
|
@ -157,7 +158,6 @@ namespace geode {
|
||||||
const char* sprName, float sprScale, BaseType type, int size, int color
|
const char* sprName, float sprScale, BaseType type, int size, int color
|
||||||
);
|
);
|
||||||
|
|
||||||
cocos2d::CCPoint getTopOffset() const;
|
|
||||||
virtual cocos2d::CCSize getMaxTopSize() const;
|
virtual cocos2d::CCSize getMaxTopSize() const;
|
||||||
|
|
||||||
virtual ~BasedButtonSprite();
|
virtual ~BasedButtonSprite();
|
||||||
|
@ -180,6 +180,11 @@ namespace geode {
|
||||||
cocos2d::CCNode* ontop, BaseType type, int size, int color
|
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;
|
cocos2d::CCNode* getTopNode() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ bool BasedButtonSprite::init(CCNode* ontop, BaseType type, int size, int color)
|
||||||
|
|
||||||
if (ontop) {
|
if (ontop) {
|
||||||
m_onTop = 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);
|
limitNodeSize(m_onTop, this->getMaxTopSize(), m_onTop->getScale(), .1f);
|
||||||
this->addChild(m_onTop);
|
this->addChild(m_onTop);
|
||||||
}
|
}
|
||||||
|
@ -202,8 +202,8 @@ CCSize BasedButtonSprite::getMaxTopSize() const {
|
||||||
return m_obContentSize - CCSize(18.f, 18.f);
|
return m_obContentSize - CCSize(18.f, 18.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCPoint BasedButtonSprite::getTopOffset() const {
|
void BasedButtonSprite::setTopOffset(CCPoint const& offset) {
|
||||||
return { 0, 0 };
|
m_topOffset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BasedButtonSprite::initWithSprite(
|
bool BasedButtonSprite::initWithSprite(
|
||||||
|
|
Loading…
Reference in a new issue