本文整理汇总了C++中TextNode::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ TextNode::setAnchorPoint方法的具体用法?C++ TextNode::setAnchorPoint怎么用?C++ TextNode::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextNode
的用法示例。
在下文中一共展示了TextNode::setAnchorPoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTitleSprite
void TitleBar::setTitleSprite(const char *name)
{
removePreTitle();
CCSprite *titleSp = CCSprite::spriteWithSpriteFrameName(name);
if(strlen(name)==0)
return;
if (!titleSp) {
titleSp = CCSprite::spriteWithFile(name);
}
if(titleSp)
{
titleSp->setPosition(ccp(58, 45));
titleSp->setAnchorPoint(ccp(0, 0.5));
addChild(titleSp);
titleSp->setTag(kTitleBarSprite);
}
else {
TextNode* titleLabel = TextNode::textWithString(name,
CCSizeMake(300, 40),
CCTextAlignmentLeft,
40);
titleLabel->setAnchorPoint(CCPointMake(0.0, 0.5));
titleLabel->setPosition(CCPointMake(60, 45));
titleLabel->setShadowColor(ccBLACK);
addChild(titleLabel);
titleLabel->setTag(kTitleBarLabel);
}
}
示例2: setTitleString
void TitleBar::setTitleString(const char* str)
{
removePreTitle();
TextNode* titleLabel = TextNode::textWithString(str, CCSizeMake(300, 40), CCTextAlignmentLeft, 40);
titleLabel->setShadowColor(ccBLACK);
titleLabel->setAnchorPoint(CCPointMake(0.0, 0.5));
titleLabel->setPosition(CCPointMake(60, 45));
addChild(titleLabel);
titleLabel->setTag(kTitleBarLabel);
}
示例3: initRetry
//******************************************************************************
// initRetry
//******************************************************************************
void CommDlg::initRetry()
{
CCSprite* sp = CCSprite::spriteWithSpriteFrameName("commdlg.png");
if(sp)
addChild(sp);
char buf[100];
initBtn();
if(m_iRc == kReqConnectErr){
//title
snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_error"));
TextNode* lbText = TextNode::textWithString(buf,45);
lbText->setPosition(CCPointMake(0, 86));
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
addChild(lbText, 1);
lbText = TextNode::textWithString(HttpComm::Inst()->getLocalErrStr().c_str(), CCSizeMake(400, 60), CCTextAlignmentCenter,26);
lbText->setPosition(CCPointMake(0, 30));
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
addChild(lbText, 1);
snprintf(buf, 99, "%s", OcProxy::Inst()->localizedStringStatic("net_again"));
lbText = TextNode::textWithString(buf,26);
lbText->setPosition(CCPointMake(0, -16));
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
addChild(lbText, 1);
}
else{
//服务器来的错误提示
const char* errMsg = CGameData::Inst()->getErrMsg();
if(errMsg != NULL){
TextNode* lbText = TextNode::textWithString(errMsg, CCSizeMake(400, 120), CCTextAlignmentCenter,26);
lbText->setAnchorPoint(CCPointMake(0.5, 1));
lbText->setPosition(CCPointMake(0, 100));
lbText->setColor(ccWHITE);
lbText->setShadowColor(ccBLACK);
addChild(lbText, 1);
}
}
}
示例4: showCardItem
void CardShop::showCardItem()
{
CCSprite* sp = CGameData::Inst()->getHeadSprite(1);
m_cardSize = sp->getContentSize();
m_iColumn = 640 / m_cardSize.width;
m_iGap = (640 - m_iColumn * m_cardSize.width) / (m_iColumn + 1);
m_ptStart.x = m_iGap;
m_ptStart.y = 720;
CCPoint pt;
m_iRmBtn = 0;
int npIndex = 0;
for (int i=0; i<pShopCardsArr->count(); i++)
{
CShopCardInfo* pShopCard = pShopCardsArr->getObjectAtIndex(i);
pt.x = m_ptStart.x + ((npIndex + m_iRmBtn) % m_iColumn) * (m_iGap + m_cardSize.width);
pt.y = m_ptStart.y - ((npIndex + m_iRmBtn) / m_iColumn) * (m_iGap + m_cardSize.height);
sp = CGameData::Inst()->getHeadSprite(pShopCard->sCid);
addChild(sp);
sp->setAnchorPoint(ccp(0,1));
sp->setPosition(pt);
sp->setTag(CARD_TAG + i);
CCSprite* spState = NULL;
switch (pShopCard->status)
{
case 1:
spState = CCSprite::spriteWithFile("card_shop_hot.png");
break;
case 2:
spState = CCSprite::spriteWithFile("card_shop_new.png");
break;
case 3:
default:
spState = CCSprite::spriteWithFile("card_shop_sale.png");
break;
}
sp->addChild(spState);
spState->setPosition(ccp(82, 82));
CCSprite* spPriceBG = CCSprite::spriteWithFile("card_shop_coin.png");
sp->addChild(spPriceBG);
spPriceBG->setPosition(ccp(56, 6));
char buf[50];
snprintf(buf, 49, "%d",pShopCard->iPrice);
TextNode* textPrice = TextNode::textWithString(buf, 16);
spPriceBG->addChild(textPrice);
textPrice->setAnchorPoint(ccp(0.5, 0));
textPrice->setPosition(ccp(68, 10));
textPrice->setColor(ccc3(250, 237, 66));
textPrice->setShadowColor(ccBLACK);
npIndex++;
}
m_shopCardNum = npIndex;
m_fUpLimitY = gfMoveDownLimitY - (pt.y - m_cardSize.height);
if (m_fUpLimitY > 0) {
m_pScrollBar = new CScrollBar();
addChild(m_pScrollBar);
m_pScrollBar->setTag(1);
m_pScrollBar->release();
float dBarSize = 1.0/((m_fUpLimitY / (m_ptStart.y - gfMoveDownLimitY))+2);
m_pScrollBar->setBarSize(dBarSize);
m_pScrollBar->setPercent(0.0);
m_pScrollBar->setPosition(CCPointMake(630, 435));
m_pScrollBar->setScaleY(1);
}
}