本文整理汇总了C++中CCScale9Sprite::getPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::getPositionY方法的具体用法?C++ CCScale9Sprite::getPositionY怎么用?C++ CCScale9Sprite::getPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCScale9Sprite
的用法示例。
在下文中一共展示了CCScale9Sprite::getPositionY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool HelpLayer::init(){
//////////////////////////////
// 1. super init first
if (!CCLayer::init()){
return false;
}
CCScale9Sprite *pBackground = CCScale9Sprite::create("Dialog_bg.png");
pBackground->setAnchorPoint(ccp(0.5f,0.5f));
CCSize frameSize = CCEGLView::sharedOpenGLView()->getFrameSize();
float scale = frameSize.width / DESIGN_WIDTH;
float newScaleY = 1.0f;
if (scale > 0){
float scaleY = frameSize.height / DESIGN_HEIGHT;
if (scaleY > scale){
newScaleY = scaleY / scale;
}
}
pBackground->setPreferredSize(CCSizeMake(DESIGN_WIDTH - 20,(DESIGN_HEIGHT - 130) * newScaleY));
CCSize size = pBackground->getContentSize();
pBackground->setPosition(VisibleRect::center());
addChild(pBackground);
CCSprite *pTitleBgSp = CCSprite::create("Dialog_Title.png");
pTitleBgSp->setPosition(ccp(pBackground->getPositionX(),pBackground->getPositionY() + pBackground->getContentSize().height / 2));
addChild(pTitleBgSp);
CCSprite *pTitleSp = CCSprite::create("Title_Help.png");
pTitleSp->setPosition(ccp(pTitleBgSp->getPositionX(),pTitleBgSp->getPositionY() + pTitleSp->getContentSize().height / 2 + 5));
addChild(pTitleSp);
CCSprite *pItemNormal = CCSprite::create("cancel_s.png");
CCSprite *pItemSelected = CCSprite::create("cancel_s.png");
CCMenuItem *pClose = CCMenuItemSprite::create(pItemNormal, pItemSelected, this, menu_selector(HelpLayer::close));
pClose->setPosition(ccp(pTitleSp->getPositionX() + pTitleSp->getContentSize().width * 3 / 2, pTitleSp->getPositionY()));
pItemSelected->setScale(1.1f);
pItemSelected->setAnchorPoint(ccp(0.05f, 0.05f));
CCMenu *pMenu = CCMenu::create(pClose, NULL);
pMenu->setPosition(CCPointZero);
addChild(pMenu, 1);
CCDictionary *text = CCDictionary::createWithContentsOfFile(XML_DATA);
CCString *msg = (CCString*)text->objectForKey("rule");
CCLabelTTF *msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
msgLabel->setColor(ccc3(0,0,0));
msgLabel->setPosition(ccp(pTitleBgSp->getPositionX(),pTitleBgSp->getPositionY() - pTitleBgSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 5));
addChild(msgLabel);
CCSprite *phSp = CCSprite::create("Help_1.png");
phSp->setPosition(ccp(msgLabel->getPositionX(),msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - phSp->getContentSize().height / 2 - 3));
addChild(phSp);
msg = (CCString*)text->objectForKey("scoreTips");
msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentCenter);
msgLabel->setColor(ccc3(0,0,0));
msgLabel->setPosition(ccp(phSp->getPositionX(),phSp->getPositionY() - phSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 10));
addChild(msgLabel);
phSp = CCSprite::create("Help_2.png");
phSp->setPosition(ccp(msgLabel->getPositionX(),msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - phSp->getContentSize().height / 2 - 3));
addChild(phSp);
msg = (CCString*)text->objectForKey("pro");
msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 21,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
msgLabel->setColor(ccc3(0,0,0));
msgLabel->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 10,
phSp->getPositionY() - phSp->getContentSize().height / 2 - msgLabel->getContentSize().height / 2 - 3));
addChild(msgLabel);
CCSprite* bombSp = CCSprite::create("Props_Bomb.png");
bombSp->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + bombSp->getContentSize().width / 2 + 10,
msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - bombSp->getContentSize().height / 2 - 3));
addChild(bombSp);
msg = (CCString*)text->objectForKey("bomb");
msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 18,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
msgLabel->setColor(ccc3(0,0,0));
msgLabel->setPosition(ccp(bombSp->getPositionX() + bombSp->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 5,
bombSp->getPositionY() + 13));
addChild(msgLabel);
msg = (CCString*)text->objectForKey("useCoin");
CCString *showUseString = CCString::createWithFormat(msg->getCString(),GameData::getInstance()->m_nBombUseCoin);
CCLabelTTF *showUseLabel = CCLabelTTF::create(showUseString->getCString(), "Arial", 14,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
showUseLabel->setColor(ccc3(0,0,0));
showUseLabel->setPosition(ccp(bombSp->getPositionX() + bombSp->getContentSize().width / 2 + showUseLabel->getContentSize().width / 2 + 5,
msgLabel->getPositionY() - msgLabel->getContentSize().height / 2 - showUseLabel->getContentSize().height / 2 - 2));
addChild(showUseLabel);
CCSprite *paintSp = CCSprite::create("Props_Paint.png");
paintSp->setPosition(ccp(pBackground->getPositionX() - pBackground->getContentSize().width / 2 + paintSp->getContentSize().width / 2 + 10,
bombSp->getPositionY() - bombSp->getContentSize().height / 2 - paintSp->getContentSize().height / 2 - 10));
addChild(paintSp);
msg = (CCString*)text->objectForKey("shua");
msgLabel = CCLabelTTF::create(msg->getCString(), "Arial", 18,CCSizeMake(DESIGN_WIDTH - 40, 0),kCCTextAlignmentLeft);
msgLabel->setColor(ccc3(0,0,0));
msgLabel->setPosition(ccp(paintSp->getPositionX() + paintSp->getContentSize().width / 2 + msgLabel->getContentSize().width / 2 + 5,
paintSp->getPositionY() + 13));
addChild(msgLabel);
//.........这里部分代码省略.........