本文整理汇总了C++中CCScale9Sprite::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::getContentSize方法的具体用法?C++ CCScale9Sprite::getContentSize怎么用?C++ CCScale9Sprite::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCScale9Sprite
的用法示例。
在下文中一共展示了CCScale9Sprite::getContentSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
LFToast::LFToast(string msg,float during)
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCScale9Sprite* base = CCScale9Sprite::create("toast.png");
CCLabelTTF* lable = CCLabelTTF::create(
msg.c_str(),
fontStr_kaiti,
30,
CCSize(base->getContentSize().width - 10,0),
kCCTextAlignmentLeft);
lable->setAnchorPoint(ccp(0,0.5f));
addChild(base);
base->setContentSize(CCSizeMake(base->getContentSize().width,lable->getContentSize().height + 20));
base->setOpacity(0);
base->addChild(lable);
lable->setPosition(ccp(10,base->getContentSize().height/2));
base->setPosition(ccp(visibleSize.width/2,base->getContentSize().height + 20));
base->runAction(CCSequence::create(
CCFadeTo::create(0.2f,255),
CCDelayTime::create(during),
CCFadeTo::create(0.1f,0),
CCCallFuncN::create(this,SEL_CallFuncN(&LFToast::removeToast)),
NULL
));
}
示例2: init
bool CCControlPotentiometerTest::init()
{
if (CCControlScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
CCNode *layer = CCNode::create();
layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2));
this->addChild(layer, 1);
double layer_width = 0;
// Add the black background for the text
CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png");
background->setContentSize(CCSizeMake(80, 50));
background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0));
layer->addChild(background);
layer_width += background->getContentSize().width;
this->setDisplayValueLabel(CCLabelTTF::create("", "HelveticaNeue-Bold", 30));
m_pDisplayValueLabel->setPosition(background->getPosition());
layer->addChild(m_pDisplayValueLabel);
// Add the slider
CCControlPotentiometer *potentiometer = CCControlPotentiometer::create("extensions/potentiometerTrack.png"
,"extensions/potentiometerProgress.png"
,"extensions/potentiometerButton.png");
potentiometer->setPosition(ccp (layer_width + 10 + potentiometer->getContentSize().width / 2, 0));
// When the value of the slider will change, the given selector will be call
potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlPotentiometerTest::valueChanged), CCControlEventValueChanged);
layer->addChild(potentiometer);
layer_width += potentiometer->getContentSize().width;
// Set the layer size
layer->setContentSize(CCSizeMake(layer_width, 0));
layer->setAnchorPoint(ccp (0.5f, 0.5f));
// Update the value label
this->valueChanged(potentiometer, CCControlEventValueChanged);
return true;
}
return false;
}
示例3:
void CCAnimate9SpriteProgress::startWithTarget(CCNode* target)
{
CCActionInterval::startWithTarget(target);
CCScale9Sprite* sprite = (CCScale9Sprite*)target;
beginSize = sprite->getContentSize();
}
示例4: initTabs
void GameRankLayer::initTabs()
{
// Friend Tab
CCScale9Sprite* ptrTabFriendsSelected = GameUtils::createScale9("new_blue_bg.png",
CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
ptrTabFriendsSelected->setContentSize(CCSizeMake(204,82));
CCScale9Sprite* ptrTabFriendsDisabled = GameUtils::createScale9("new_blue_bg.png",
CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
ptrTabFriendsDisabled->setContentSize(CCSizeMake(204,82));
CCNode* ptrTabFriendsNormal = CCNode::create();
ptrTabFriendsNormal->setContentSize(ptrTabFriendsSelected->getContentSize());
m_ptrTabFriends = CCMenuItemSprite::create(ptrTabFriendsNormal, ptrTabFriendsSelected,
ptrTabFriendsDisabled, this, menu_selector(GameRankLayer::tabFriendsCallback));
m_ptrBg->addChild(m_ptrTabFriends);
LayoutUtil::layoutParentLeftTop(m_ptrTabFriends, -5, -27);
registerMenuItem(m_ptrTabFriends);
m_ptrLbFriends = CCLabelBMFont::create(LOCALIZED_STRING("word_friends"),
FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE);
m_ptrLbFriends->setScale(0.6f);
m_ptrTabFriends->addChild(m_ptrLbFriends);
LayoutUtil::layoutParentBottom(m_ptrLbFriends,6,22);
// Global Tab
CCScale9Sprite* ptrTabGlobalSelected = GameUtils::createScale9("new_blue_bg.png",
CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
ptrTabGlobalSelected->setContentSize(CCSizeMake(204,82));
CCScale9Sprite* ptrTabGlobalDisabled = GameUtils::createScale9("new_blue_bg.png",
CCRectMake(0,0,200,82),CCRectMake(35,35,125,10));
ptrTabGlobalDisabled->setContentSize(CCSizeMake(204,82));
CCNode* ptrTabGlobalNormal = CCNode::create();
ptrTabGlobalNormal->setContentSize(ptrTabGlobalSelected->getContentSize());
m_ptrTabGolbal = CCMenuItemSprite::create(ptrTabGlobalNormal, ptrTabGlobalSelected,
ptrTabGlobalDisabled,this, menu_selector(GameRankLayer::tabGlobalCallback));
m_ptrBg->addChild(m_ptrTabGolbal);
LayoutUtil::layoutRight(m_ptrTabGolbal,m_ptrTabFriends,-44);
registerMenuItem(m_ptrTabGolbal);
m_ptrLbGlobal = CCLabelBMFont::create(LOCALIZED_STRING("word_global"),
FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE);
m_ptrLbGlobal->setScale(0.6f);
m_ptrTabGolbal->addChild(m_ptrLbGlobal);
LayoutUtil::layoutParentBottom(m_ptrLbGlobal,5,22);
tabFriendsCallback(NULL);
}
示例5: showImmediately
void AchievementNotification::showImmediately(Achievement a)
{
mShowing = true;
CCTexture2D* tex = CCTextureCache::sharedTextureCache()->textureForKey(fileName.c_str());
if (tex == NULL)
{
tex = CCTextureCache::sharedTextureCache()->addImage(fileName.c_str());
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite* pBoard = CCScale9Sprite::create(CCRectMake(tex->getContentSize().width/2, 0, 2, tex->getContentSize().height), fileName.c_str());
addChild(pBoard,0,Tag_Board);
pBoard->setPosition(ccp(winSize.width/2,winSize.height + pBoard->getContentSize().height) );
CCSprite* pJinBei = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_jiangbei.png").c_str());
pBoard->addChild(pJinBei, 1);
pJinBei->setPosition(ccp(pJinBei->getContentSize().width, pBoard->getContentSize().height/2));
CCLabelTTF* pName = CCLabelTTF::create(a.name.c_str(), fontStr_KlavikaBold, 40);
pName->setColor(fontColor_Acheivement_TTF);
CCSprite* pIcon = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_wancheng.png").c_str());
int x = pName->getContentSize().width + pIcon->getContentSize().width - 420;
if (x > 0)
{
pBoard->setContentSize(ccp(pBoard->getContentSize().width+x, pBoard->getContentSize().height));
}
pBoard->addChild(pName);
int xoffset = 10;
pName->setPosition(ccp(pBoard->getContentSize().width/2 + pIcon->getContentSize().width/2 + xoffset, pBoard->getContentSize().height/2));
pBoard->addChild(pIcon);
pIcon->setPosition(ccp(pName->getPositionX() - pName->getContentSize().width/2 - pIcon->getContentSize().width/2 - xoffset, pName->getPositionY()));
Achievement* achievementCopy = new Achievement(a);
// *achievementCopy = a;
temp_Must_Delete.insert(temp_Must_Delete.end(),achievementCopy);
pBoard->runAction(CCSequence::create(
CCMoveTo::create(0.5f,ccp(pBoard->getPositionX(),winSize.height-pBoard->getContentSize().height/2)),
CCDelayTime::create(0.1f),
CCCallFuncND::create(this,SEL_CallFuncND(&AchievementNotification::boardShowing),achievementCopy),
CCDelayTime::create(1.3f),
CCMoveTo::create(0.2f,ccp(pBoard->getPositionX(),winSize.height+pBoard->getContentSize().height)),
CCFadeTo::create(0.1f,0),
CCCallFuncN::create(this,SEL_CallFuncN(&AchievementNotification::boardShowEnd)),NULL));
createPar(ccp(winSize.width/2,winSize.height),parFileName.c_str(),pBoard->getContentSize().width * 1.2f,pBoard->getContentSize().height);
Music::sharedMusicPlayer()->playEffectSound("achievement.wav");
CCLog("AchievementNotification::showImmediately name = %s" ,a.name.c_str());
}
示例6: onEnter
void PopCancelLayer::onEnter(){
PopLayer::onEnter();
CCMenuItemImage* cancelBtn = CCMenuItemImage::create("strangedesign/Dlg_cancel_button.png",
"strangedesign/Dlg_cancel_button_down.png",
this,
menu_selector(PopCancelLayer::cancelCallback));
CCScale9Sprite* background = getSprite9BackGround();
CCPoint centerDlg = background->getPosition();
CCSize backgroundSize = background->getContentSize();
CCPoint rightCorner = centerDlg+ccp(backgroundSize.width/2, backgroundSize.height/2);
CCSize cancelImgSize = cancelBtn->getContentSize();
cancelBtn->setPosition(rightCorner-ccp(cancelImgSize.width/2,cancelImgSize.height/2));
getMenuButton()->addChild(cancelBtn);
}
示例7: init
bool CCControlScene::init()
{
if (CCLayer::init())
{
// Get the sceensize
CCSize screensize = CCDirector::sharedDirector()->getWinSize();
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
menu_selector(CCControlScene::toExtensionsMainLayer));
pBackItem->setPosition(ccp(screensize.width - 50, 25));
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
pBackMenu->setPosition( CCPointZero );
addChild(pBackMenu, 10);
// Add the generated background
CCSprite *background = CCSprite::create("extensions/background.png");
background->setPosition(ccp(screensize.width / 2, screensize.height / 2));
addChild(background);
// Add the ribbon
CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55));
ribbon->setContentSize(CCSizeMake(screensize.width, 57));
ribbon->setPosition(ccp(screensize.width / 2.0f, screensize.height - ribbon->getContentSize().height / 2.0f));
addChild(ribbon);
// Add the title
setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12));
m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
addChild(m_pSceneTitleLabel, 1);
// Add the menu
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(screensize.width / 2 - 100, 37));
item2->setPosition(ccp(screensize.width / 2, 35));
item3->setPosition(ccp(screensize.width / 2 + 100, 37));
addChild(menu ,1);
return true;
}
return false;
}
示例8: init
bool CCControlScene::init()
{
if (CCLayer::init())
{
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
menu_selector(CCControlScene::toExtensionsMainLayer));
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
pBackMenu->setPosition( CCPointZero );
addChild(pBackMenu, 10);
// Add the generated background
CCSprite *background = CCSprite::create("extensions/background.png");
background->setPosition(VisibleRect::center());
addChild(background);
// Add the ribbon
CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55));
ribbon->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, 57));
ribbon->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f));
addChild(ribbon);
// Add the title
setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12));
m_pSceneTitleLabel->setPosition(ccp (VisibleRect::center().x, VisibleRect::top().y - m_pSceneTitleLabel->getContentSize().height / 2 - 5));
addChild(m_pSceneTitleLabel, 1);
// Add the menu
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
menu->setPosition(CCPointZero);
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu ,1);
return true;
}
return false;
}
示例9: initView
//.........这里部分代码省略.........
str_vec.push_back("purpleBg.png");
str_vec.push_back("orangeBg.png");
}
//inphone 5 根据武将地图来
else
{
str_vec.push_back("greenBgI5.png");
str_vec.push_back("blueBgI5.png");
str_vec.push_back("purpleBgI5.png");
str_vec.push_back("orangeBgI5.png");
}
int starLev = _card->getCurrStar();
starLev = starLev<3?3:starLev;
starLev = starLev>6?6:starLev;
//光效背景图片
CCSprite * lightBg = CCSprite::createWithSpriteFrameName(str_vec[starLev-3].c_str());
this->addChild(lightBg , 0 , 1919);
float adjustY = 0;
CCSprite *bigbg = NULL;
item->setAnchorPoint(ccp(0.5, 0));
if (winSize.height == 960)
{
adjustY = 40;
frameSize = CCRectMake(0, 0 , 768, 413);
this->setItemID("pad装备底图.png",true);
fermEffect->setScale(winSize.width/768);
fermEffect1->setScale(winSize.width/768);
fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -287 +26)));
fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -287 +26)));
item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -365)));
lightBg->setZOrder(0);
lightBg->setScaleX(winSize.width / lightBg->getContentSize().width);
lightBg->setScaleY(1.6);
lightBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),
ccp(0, -title_bg->getContentSize().height - lightBg->getContentSize().height*0.5*lightBg->getScaleY())));;
}
else if (winSize.height == 1136)
{
adjustY=31;
frameSize = CCRectMake(0, 520 -(winSize.height - hgt*1.18 - title_bg->getContentSize().height), 768, (winSize.height - hgt*1.18 - title_bg->getContentSize().height));
this->setItemID("carditembg.png",true);
fermEffect->setScaleX(winSize.width/768);
fermEffect1->setScaleX(winSize.width/768);
fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -361+26)));
fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -361+26)));
item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -450)));
CCSprite *temp = CCSprite::createWithSpriteFrameName("carditembg.png");
lightBg->setScaleX(winSize.width / lightBg->getContentSize().width);
lightBg->setScaleY(temp->getContentSize().height * 0.75 / lightBg->getContentSize().height);
lightBg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),
ccp(0, -title_bg->getContentSize().height - temp->getContentSize().height * 0.8 /2 + 16) ));
}
else
{
adjustY = 55;
bigbg = CCSprite::createWithSpriteFrameName("pad装备底图.png");
this->addChild(bigbg,-100);
示例10: 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);
//.........这里部分代码省略.........
示例11: SetBgAni
void CCtrlPage::SetBgAni(const char* pszAni)
{
if (NULL == pszAni)
{
return;
}
clearBackgroundSprite();
m_strAniSection = std::string(pszAni);
if (m_strAniSection.empty())
{
return;
}
CMyIniPtr pAni = g_objIniMgr.GetMyIniPtr(m_strAniPath.c_str());
if (!pAni)
{
return;
}
int nFrame = 0;
std::string strFrame = FORMAT("Frame%d")<<nFrame;
const char *pszValue = pAni->GetString(m_strAniSection.c_str(), strFrame.c_str());
if (NULL == pszValue)
{
return;
}
CCScale9Sprite *backgroundSprite = CCScale9Sprite::create(pszValue);
if (!backgroundSprite)
{
return;
};
// 不为9宫格方式
if (enumUISTRETCH_NORMAL == m_nAniStretch)
{
CCRect rectCapInsets = CCRectMake(0, 0, backgroundSprite->getContentSize().width, backgroundSprite->getContentSize().height);
backgroundSprite->removeAllChildren();
CCScale9Sprite *backgroundSpriteResize = backgroundSprite->resizableSpriteWithCapInsets(rectCapInsets);
CHECK(backgroundSpriteResize);
setBackgroundSprite(backgroundSpriteResize);
}
else if (enumUISTRETCH_STRETCH == m_nAniStretch)
{
float fOrgWidth = backgroundSprite->getContentSize().width;
float fOrgHeight = backgroundSprite->getContentSize().height;
CCRect rectCapInsets = CCRectMake(0, 0, fOrgWidth, fOrgHeight);
backgroundSprite->removeAllChildren();
CCScale9Sprite *backgroundSpriteResize = backgroundSprite->resizableSpriteWithCapInsets(rectCapInsets);
CHECK(backgroundSpriteResize);
float fScaleX = 1.0f;
float fScaleY = 1.0f;
if (0.0f != fOrgWidth && 0.0f != fOrgHeight)
{
fScaleX = (float)m_nWidth / fOrgWidth;
fScaleY = (float)m_nHeight / fOrgHeight;
}
backgroundSpriteResize->setScaleX(fScaleX);
backgroundSpriteResize->setScaleY(fScaleY);
setBackgroundSprite(backgroundSpriteResize);
}
else
{
setBackgroundSprite(backgroundSprite);
}
CHECK(m_backgroundSprite);
m_backgroundSprite->setAnchorPoint(ccp(0, 0));
m_backgroundSprite->setPosition(ccp(0, 0));
this->addChild(m_backgroundSprite, 0);
}
示例12: initView
void SGConsumableInfoLayer::initView()
{
ResourceManager::sharedInstance()->bindTexture("animationFile/qhtexiao.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
ResourceManager::sharedInstance()->bindTexture("sgequipslayer/sgequipslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
ResourceManager::sharedInstance()->bindTexture("sggeneralinfolayer/sggeneralinfolayer1.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
ResourceManager::sharedInstance()->bindTexture("sgrewardlayer/sgrewardlayer2.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
ResourceManager::sharedInstance()->bindTexture("sgsoldierslayer/sgsoldierslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer, LIM_PNG_AS_PNG);
ResourceManager::sharedInstance()->bindTexture("sgpropslayer/sgpropslayer.plist",RES_TYPE_LAYER_UI ,sg_comsumableInfoLayer);
CCSize s = CCDirector::sharedDirector()->getWinSize();
float btmheight = SGMainManager::shareMain()->getBottomHeight();
//float frameheight = skewingY(155);
float hgt = skewingY(244);
if (s.height == 1136) {
//frameheight = skewing(155);
hgt = skewing(244);
}
//左火
CCSpriterX *fermEffect = CCSpriterX::create("animationFile/qhhyA.scml", true, true);
fermEffect->setanimaID(0);
fermEffect->setisloop(true);
addChild(fermEffect, 10, 0);
//右火
CCSpriterX *fermEffect1 = CCSpriterX::create("animationFile/qhhyB.scml", true, true);
fermEffect1->setCCSpriterXFlipX(true);
fermEffect1->setanimaID(0);
fermEffect1->setisloop(true);
addChild(fermEffect1, 10, 1);
CCLOG("type%d",_card->getItemType());
// if (_card->getType()) {
// statements
// }
SGMainManager::shareMain()->addPropPng(_card->getHeadSuffixNum(),sg_comsumableInfoLayer);
CCString *str = CCString::createWithFormat("prop%d.png",_card->getHeadSuffixNum());
CCSprite *item = CCSprite::createWithSpriteFrameName(str->getCString());
this->addChild(item,2);
item->setAnchorPoint(ccp(0.5, 0));
if (s.height == 960) {
frameSize = CCRectMake(0, 0 , 768, 413);
this->setItemID("pad装备底图.png",true);
fermEffect->setScale(s.width/768);
fermEffect1->setScale(s.width/768);
fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -287+26)));
fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -287+26)));
item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -365)));
}
else if (s.height == 1136) {
frameSize = CCRectMake(0, 520 -(s.height - hgt*1.13 - title_bg->getContentSize().height), 768, (s.height - hgt*1.13 - title_bg->getContentSize().height));
this->setItemID("carditembg.png",true);
fermEffect->setScaleX(s.width/768);
fermEffect1->setScaleX(s.width/768);
fermEffect->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(-264, -361+26)));
fermEffect1->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(264, -361+26)));
item->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, -450)));
}else
{
CCSprite *a = CCSprite::createWithSpriteFrameName("pad装备底图.png");
this->addChild(a,-100);
a->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter), ccp(0, - title_bg->getContentSize().height - a->getContentSize().height*.45)));
fermEffect->setPosition(ccpAdd(a->getPosition(), ccp(-a->getContentSize().width*.41, a->getContentSize().height*.02 -a->getContentSize().height*.09)));
fermEffect1->setPosition(ccpAdd(a->getPosition(), ccp(a->getContentSize().width*.41, a->getContentSize().height*.02-a->getContentSize().height*.09)));
item->setPosition(ccpAdd(a->getPosition(), ccp(0, -a->getContentSize().height*.362)));
}
fermEffect->play();
fermEffect1->play();
menu->setZOrder(7);
this->setstar(_card->getCurrStar());
this->setTitle(_card->getOfficerName()->getCString());
SGButton *backBtn = SGButton::createFromLocal("store_exchangebtnbg.png", str_back,
this, menu_selector(SGConsumableInfoLayer::backHandler),CCPointZero,FONT_PANGWA,ccWHITE,32);
backBtn->setScale(1.05);
this->addBtn(backBtn);
backBtn->setPosition(ccpAdd(SGLayout::getPoint(kUpLeft), ccp( backBtn->getContentSize().width*.55, - backBtn->getContentSize().height*.55)));
if(enterType == 101)
{
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/barrack_bg.plist", RES_TYPE_LAYER_UI, sg_comsumableInfoLayer);
CCSprite *bg1 = CCSprite::create("storyBg.png");
//CCRect r = CCRectMake(0, 1136/2 - (hgt*1.13)/2, s.width, hgt*1.13);
//bg1->setTextureRect(r);
bg1->setScaleY(s.height/2 / bg1->getContentSize().height);
//.........这里部分代码省略.........