本文整理汇总了C++中CCScale9Sprite::setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::setPreferredSize方法的具体用法?C++ CCScale9Sprite::setPreferredSize怎么用?C++ CCScale9Sprite::setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCScale9Sprite
的用法示例。
在下文中一共展示了CCScale9Sprite::setPreferredSize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
CCScale9Sprite* TFBaseLayer::createTile(const char* spriteFrameName, CCSize size, CCPoint position)
{
CCScale9Sprite* tile = CCScale9Sprite::createWithSpriteFrameName(spriteFrameName);
tile->setPreferredSize(size);
tile->setAnchorPoint(ccp(0.5f, 0.5f));
tile->setPosition(position);
return tile;
}
示例2: resetScroll
void resetScroll(){
if(!_scrollBar){ return;}
CCSize vs = getViewSize(), cs = getContentSize();
bool vert = getDirection() == kCCScrollViewDirectionVertical;
bool v = vert? vs.height < cs.height : vs.width < cs.height;
_scrollBar->setVisible(v);
CCPoint p = ccp(0, 0), ap = vert? ccp(1,0) : CCPointZero;
if(v){
CCSize s = _scrollBar->getPreferredSize(),
st = _scrollTrack? _scrollTrack->getPreferredSize() : CCSizeZero;
if(vert){
p.x = vs.width + _scrollOffset - (st.width > 0? (st.width - s.width) / 2 : 0);
_scrollTrackDelta = st.height > 0? (st.height - s.height) / 2 : 0;
s.height = vs.height / cs.height * vs.height - _scrollTrackDelta * 2;
}else{
p.y = vs.height + _scrollOffset - (st.height > 0? (st.height - s.height) / 2 : 0);
_scrollTrackDelta = st.width > 0? (st.width - s.width) / 2 : 0;
s.width = vs.width / cs.width * vs.width - _scrollTrackDelta * 2;
}
_scrollBar->setAnchorPoint(ap);
_scrollBar->setPreferredSize(s);
_scrollBar->setPosition(p);
//CCLog("LuaTableView vScroll.size=%d,%d vh=%d ch=%d", (int)s.width, (int)s.height, (int)vs.height, (int)cs.height);
}
if(_scrollTrack){
_scrollTrack->setVisible(v);
if(v){
CCSize s = _scrollTrack->getPreferredSize();
if(vert){
p.x = vs.width + _scrollOffset;
s.height = vs.height;
}else{
p.y = vs.height + _scrollOffset;
s.width = vs.width;
}
_scrollTrack->setAnchorPoint(ap);
_scrollTrack->setPreferredSize(s);
_scrollTrack->setPosition(p);
}
}
//CCLog("LuaTableView reload vscr=%x visible=%d", _scroller, _scrollBar->isVisible());
updateScroll();
}
示例3: updateProgress
void BBProgressBar::updateProgress()
{
float pv = (m_fCurrent - m_fMin) / (m_fMax - m_fMin);
if(m_fMax - m_fMin == 0) pv=0;
if(pv<0) pv=0;
if(pv>1) pv=1;
switch (m_nProgressBarMode)
{
case BB_PROGRESSBAR_MODE_SCALE:
{
}
break;
//基于9格缩放的进度条机制
case BB_PROGRESSBAR_MODE_LAYOUT:
{
CCSize sizeLayout = m_pBackground->getContentSize();
sizeLayout.width *= pv;
CCScale9Sprite* pro = dynamic_cast<CCScale9Sprite*>(m_pProgress);
if(pro)
{
pro->setPreferredSize(sizeLayout);
if(m_bHideProgress) pro->setVisible(false);
else if(pv>0.01) pro->setVisible(true);
else pro->setVisible(false);
}
if(m_pLabel)
{
m_pLabel->setString(FORMAT("%d", (int)m_fCurrent));
}
}
break;
case BB_PROGRESSBAR_MODE_CIRCLE:
{
if(m_pPotentiometer)
{
m_pPotentiometer->setMaximumValue(m_fMax);
m_pPotentiometer->setMinimumValue(m_fMin);
m_pPotentiometer->setValue(m_fCurrent);
}
}
break;
}
};
示例4: setPreferredSize
void CCControlButton::setPreferredSize(CCSize size)
{
if(size.width == 0 && size.height == 0)
{
m_doesAdjustBackgroundImage = true;
}
else
{
m_doesAdjustBackgroundImage = false;
CCDictElement * item = NULL;
CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item)
{
CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject();
sprite->setPreferredSize(size);
}
}
示例5: createChildren
void AchieveItemSprite::createChildren(AchieveManager::AchieveVO vo)
{
CCSprite *p = CCSprite::create(g_sAchieveItemBGImage);
CCSize ps = p->getContentSize();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite* bg = CCScale9Sprite::create(g_sAchieveItemBGImage,CCRectMake(0,0,ps.width,ps.height),CCRectMake(20,20,ps.width-40,ps.height-40));
this->addChild(bg);
char url[64] = {0};
sprintf(url,"%s%d%s", "./image/achieve/", vo.id, ".png");
CCSprite* pic = CCSprite::create(url);
this->addChild(pic);
//this->setTouchEnabled(false);
bg->setPreferredSize(CCSizeMake(350,120));
}
示例6: onEnterTransitionDidFinish
void CAButton::onEnterTransitionDidFinish()
{
CAView::onEnterTransitionDidFinish();
if (this->CAControl::getBackGroundView() == NULL)
{
this->setBackGroundDefault();
}
if (this->getHighlightedBackGroundView() == NULL)
{
if (CCScale9Sprite* bg = dynamic_cast<CCScale9Sprite*>(this->CAControl::getBackGroundView()))
{
CCScale9Sprite* bgHighLighted = CCScale9Sprite::createWithImage(bg->getImage());
bgHighLighted->setPreferredSize(bg->getPreferredSize());
bgHighLighted->setColor(ccc3(127, 127, 127));
this->setBackGround(CAControlStateHighlighted, bgHighLighted);
}
else if (CAImageView* bg = dynamic_cast<CAImageView*>(this->CAControl::getBackGroundView()))
{
CAImageView* bgHighLighted = CAImageView::createWithImage(bg->getImage());
bgHighLighted->setBounds(bg->getBounds());
bgHighLighted->setColor(ccc3(127, 127, 127));
this->setBackGround(CAControlStateHighlighted, bgHighLighted);
}
else if (CAView* bg = dynamic_cast<CAView*>(this->CAControl::getBackGroundView()))
{
CAView* bgHighLighted = CAView::createWithFrame(bg->getFrame());
bgHighLighted->setColor(ccc3(bg->getColor().r/2, bg->getColor().g/2, bg->getColor().b/2));
this->setBackGround(CAControlStateHighlighted, bgHighLighted);
}
}
this->updateWithPoint();
this->setControlStateNormal();
}
示例7: setPreferredSize
void CCControlButton::setPreferredSize(CCSize size)
{
if(size.width == 0 && size.height == 0)
{
m_doesAdjustBackgroundImage = true;
}
else
{
m_doesAdjustBackgroundImage = false;
CCScale9Sprite* item = NULL;
CCControlState key =0;
m_backgroundSpriteDispatchTable->begin();
while ( (item = m_backgroundSpriteDispatchTable->next(&key))!=NULL)
{
CCScale9Sprite* sprite = (CCScale9Sprite*)item;
sprite->setPreferredSize(size);
}
m_backgroundSpriteDispatchTable->end();
}
m_preferredSize = size;
needsLayout();
}
示例8: initView
//.........这里部分代码省略.........
equipStrengBtn = SGButton::createFromLocal(IMG_BTN_ON, str_qianghua_, this, menu_selector(SGEquipStrengLayer::equipStrengHandler),CCPointZero,FONT_PANGWA,ccWHITE,32,false,true);
this->addBtn(equipStrengBtn);
if(winSize.height==1136)
equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7+ adjustY*0.6));
else if (winSize.height == 1024)
equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7));
else
equipStrengBtn->setPosition(ccp(winSize.width/2- btnwid*3 - btnwidth - adpt_wid, btmheight*.55 + equipStrengBtn->getContentSize().height*0.7 + 10));
equipAutoStrengBtn = SGButton::createFromLocal(IMG_BTN_ON, str_autoqianghua, this, menu_selector(SGEquipStrengLayer::autoEquipStrengHandler),CCPointZero,FONT_PANGWA,ccWHITE,32,false,true);
this->addBtn(equipAutoStrengBtn);
equipAutoStrengBtn->setPosition(ccpAdd(equipStrengBtn->getPosition(), ccp( equipAutoStrengBtn->getContentSize().width - adpt_wid,0 )));
int limittag = SGStaticDataManager::shareStatic()->getimitTagById(limitEquipGuide,9);
equipAutoStrengBtn->setTag(limittag);
SGButton *backBtn = SGButton::createFromLocal(IMG_BTN_ON, str_Back_, this, menu_selector(SGEquipStrengLayer::backHandler),CCPointZero,FONT_PANGWA,ccWHITE,32);
backBtn->setScale(1.05);
this->addBtn(backBtn);
backBtn->setPosition(ccpAdd(equipAutoStrengBtn->getPosition(), ccp( backBtn->getContentSize().width - adpt_wid,0)));
SGEquipmentDataModel *general = SGStaticDataManager::shareStatic()->getEquipById(_card->getItemId());
this->setCardType(general->getEquipType());
////////////////////////
float bigFrmWidth = winSize.width - 40;
float bigFrmHeight = (int)winSize.height/3 -20;
CCScale9Sprite *bigFrm = CCScale9Sprite::createWithSpriteFrameName("barrack_kuang.png");
bigFrm->setPreferredSize(CCSizeMake(bigFrmWidth, bigFrmHeight));
this->addChild(bigFrm,7);
if(winSize.height==1136)
bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 4 + adjustY*0.6)));
else if(winSize.height==1024)
bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 4)));
else
bigFrm->setPosition(ccpAdd(ccp(winSize.width/2,equipStrengBtn->getPosition().y), ccp(0, equipStrengBtn->getContentSize().height/2 + bigFrmHeight/2 + 10 )));
CCSprite *bigFrmBg = CCSprite::createWithSpriteFrameName("barrack_kuangbg.png");
this->addChild(bigFrmBg,6);
bigFrmBg->setScaleX(bigFrmWidth/bigFrmBg->getContentSize().width);
bigFrmBg->setScaleY(bigFrmHeight/bigFrmBg->getContentSize().height);
bigFrmBg->setPosition(bigFrm->getPosition());
CCSprite* admsBkg = CCSprite::createWithSpriteFrameName("store_redbg.png");
float scaleX = winSize.width / admsBkg->getContentSize().height;
float scaleY = 60 / admsBkg->getContentSize().height;
admsBkg->setScaleX(scaleX);
admsBkg->setScaleY(scaleY);
this->addChild(admsBkg, 9);
// admsBkg->setPosition(ccpAdd(bigFrm->getPosition(), ccp(0,admsBkg->getContentSize().height*scaleY/2 + bigFrm->getContentSize().height/2) ));
admsBkg->setPosition(ccpAdd(lightBg->getPosition(), ccp(0, -lightBg->getScaleY() *lightBg->getContentSize().height*0.5 - admsBkg->getContentSize().height*0.5*lightBg->getScaleY() + adjustY)) );
/////////////////////////////////
equipName = SGCCLabelTTF::create(_card->getOfficerName()->getCString(), FONT_PANGWA, 26);
equipName->setPosition(ccpAdd(bigFrm->getPosition(), ccp(-40,bigFrm->getContentSize().height/2 - 26 )));
int equipStar = _card->getCurrStar() - 2;
equipStar = equipStar < 0 ? 0 : equipStar;
if (equipStar >= 0 && equipStar < 5) {
equipName->setInsideColor(ccStarLevelColor[equipStar]);
}
示例9: setIndicator
void CAIndicator::setIndicator(const CCSize& parentSize, const CCRect& childrenFrame)
{
CCScale9Sprite* indicator = dynamic_cast<CCScale9Sprite*>(m_pIndicator);
int x = (int)indicator->getCenterOrigin().x * 10;
int y = (int)indicator->getCenterOrigin().y * 10;
if (m_eType == CAIndicatorTypeHorizontal)
{
float size_scale_x = parentSize.width / childrenFrame.size.width;
size_scale_x = MIN(size_scale_x, 1.0f);
float lenght_scale_x = parentSize.width / 2 - childrenFrame.origin.x;
lenght_scale_x /= childrenFrame.size.width;
CCSize size = m_obContentSize;
size.width *= size_scale_x;
if (lenght_scale_x < size_scale_x / 2)
{
size.width *= lenght_scale_x / (size_scale_x / 2);
}
if (1 - lenght_scale_x < size_scale_x / 2)
{
size.width *= (1 - lenght_scale_x) / (size_scale_x / 2);
}
size.width = MAX(size.height, size.width);
indicator->setPreferredSize(size);
CCPoint point = m_obContentSize;
point.y *= 0.5f;
point.x *= lenght_scale_x;
point.x = MAX(point.x, size.width/2);
point.x = MIN(point.x, m_obContentSize.width - size.width/2);
indicator->setCenterOrigin(point);
}
else if (m_eType == CAIndicatorTypeVertical)
{
float size_scale_y = parentSize.height / childrenFrame.size.height;
size_scale_y = MIN(size_scale_y, 1.0f);
float lenght_scale_y = parentSize.height / 2 - childrenFrame.origin.y;
lenght_scale_y /= childrenFrame.size.height;
CCSize size = m_obContentSize;
size.height *= size_scale_y;
if (lenght_scale_y < size_scale_y / 2)
{
size.height *= lenght_scale_y / (size_scale_y / 2);
}
if (1 - lenght_scale_y < size_scale_y / 2)
{
size.height *= (1 - lenght_scale_y) / (size_scale_y / 2);
}
size.height = MAX(size.height, size.width);
indicator->setPreferredSize(size);
CCPoint point = m_obContentSize;
point.x *= 0.5f;
point.y *= lenght_scale_y;
point.y = MAX(point.y, size.height/2);
point.y = MIN(point.y, m_obContentSize.height - size.height/2);
indicator->setCenterOrigin(point);
}
do
{
if (x == (int)indicator->getCenterOrigin().x * 10 && y == (int)indicator->getCenterOrigin().y * 10)
{
CC_BREAK_IF(indicator->getActionByTag(0xfff));
CC_BREAK_IF(indicator->getOpacity() < 255);
CCDelayTime* delayTime = CCDelayTime::create(0.2f);
CCFadeOut* fadeOut = CCFadeOut::create(0.3f);
CCEaseSineOut* easeSineOut = CCEaseSineOut::create(fadeOut);
CCSequence* actions = CCSequence::create(delayTime, easeSineOut, NULL);
actions->setTag(0xfff);
this->runAction(actions);
}
else
{
CC_BREAK_IF(indicator->getOpacity() == 255);
indicator->stopAllActions();
this->setOpacity(255);
}
}
while (0);
}
示例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: init
bool BuyLifeLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF (!CCLayer::init());
CCSprite *p = CCSprite::create(g_sPanelBGImage);
CCSize ps = p->getContentSize();
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite * bg = CCScale9Sprite::create(g_sPanelBGImage,CCRectMake(0,0,ps.width,ps.height),CCRectMake(20,20,ps.width-40,ps.height-40));
this->addChild(bg);
bg->setAnchorPoint(ccp(0,0));
bg->setPreferredSize(CCSizeMake(s.width,s.height-beginY));
this->setTouchEnabled(true);
this->setTouchPriority(-999);
p = CCSprite::create(g_sPanelBGImage2);
ps = p->getContentSize();
bg = CCScale9Sprite::create(g_sPanelBGImage2,CCRectMake(0,0,ps.width,ps.height),CCRectMake(20,20,ps.width-40,ps.height-40));
this->addChild(bg);
bg->setAnchorPoint(ccp(0,0));
bg->setPreferredSize(CCSizeMake(s.width-20,s.height-20-beginY));
bg->setPositionX(10);
bg->setPositionY(10);
CCMenuItemImage * back = CCMenuItemImage::create(g_sBackButtonUpBGImage,g_sBackButtonDownBGImage,
this,
menu_selector(BuyLifeLayer::onCommandBack));
back->setAnchorPoint(ccp(0,1));
MyCCMenu * backMenu = MyCCMenu::create(back,NULL);
this->addChild(backMenu);
backMenu->setPositionX(28);
backMenu->setPositionY(1000-beginY);
backMenu->setTouchPriority(-1000);
CCSprite * t2 = CCSprite::create(g_sBigLifeBGImage);
t2->setAnchorPoint(ccp(0,1));
t2->setPosition(ccp(82,890-beginY));
this->addChild(t2);
CCSprite * price2 = CCSprite::create(g_sBuy2BGImage);
price2->setAnchorPoint(ccp(0,1));
price2->setPosition(ccp(157,889-beginY));
this->addChild(price2);
CCSprite * coin2 = CCSprite::create(g_sGoldBGImage);
coin2->setAnchorPoint(ccp(0,1));
coin2->setPosition(ccp(392,891-beginY));
this->addChild(coin2);
CCMenuItemImage * buy2 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
this,
menu_selector(BuyLifeLayer::onCommandBuy2));
buy2->setAnchorPoint(ccp(0,1));
MyCCMenu * buy2Menu = MyCCMenu::create(buy2,NULL);
this->addChild(buy2Menu);
buy2Menu->setPositionX(534);
buy2Menu->setPositionY(907-beginY);
buy2Menu->setTouchPriority(-1000);
CCSprite * t5 = CCSprite::create(g_sBigLifeBGImage);
t5->setAnchorPoint(ccp(0,1));
t5->setPosition(ccp(82,719-beginY));
this->addChild(t5);
CCSprite * price5 = CCSprite::create(g_sBuy5BGImage);
price5->setAnchorPoint(ccp(0,1));
price5->setPosition(ccp(157,718-beginY));
this->addChild(price5);
CCSprite * coin5 = CCSprite::create(g_sGoldBGImage);
coin5->setAnchorPoint(ccp(0,1));
coin5->setPosition(ccp(392,723-beginY));
this->addChild(coin5);
CCMenuItemImage * buy5 = CCMenuItemImage::create(g_sOkButtonUpBGImage,g_sOkButtonDownBGImage,
this,
menu_selector(BuyLifeLayer::onCommandBuy5));
buy5->setAnchorPoint(ccp(0,1));
MyCCMenu * buy5Menu = MyCCMenu::create(buy5,NULL);
this->addChild(buy5Menu);
buy5Menu->setPositionX(534);
buy5Menu->setPositionY(736-beginY);
buy5Menu->setTouchPriority(-1000);
CCSprite * t21 = CCSprite::create(g_sBigLifeBGImage);
t21->setAnchorPoint(ccp(0,1));
t21->setPosition(ccp(82,550-beginY));
this->addChild(t21);
CCSprite * price21 = CCSprite::create(g_sBuy21BGImage);
price21->setAnchorPoint(ccp(0,1));
price21->setPosition(ccp(152,550-beginY));
this->addChild(price21);
CCSprite * coin21 = CCSprite::create(g_sGoldBGImage);
//.........这里部分代码省略.........
示例12: initView
//.........这里部分代码省略.........
}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);
bg1->setScaleX(s.width / bg1->getContentSize().width);
bg1->setAnchorPoint(ccp(0.5, 0));
bg1->setPosition(SGLayout::getPoint(kBottomCenter));
this->addChild(bg1,5);
}
else
{
CCSprite *bg1 = CCSprite::createWithSpriteFrameName("info_redbg.png");
bg1->setAnchorPoint(ccp(0.5, 0));
bg1->setScaleX(s.width/bg1->getContentSize().width);
bg1->setScaleY((hgt*1.13-btmheight*.68)/bg1->getContentSize().height);
bg1->setPosition(ccpAdd(SGLayout::getPoint(kBottomCenter), ccp(0, btmheight*.68 )));
this->addChild(bg1,5);
}
CCSprite* jinbian = CCSprite::createWithSpriteFrameName("jinbian.png");
jinbian->setPosition(ccp(s.width/2, hgt*1.13));
jinbian->setScaleX(s.width/jinbian->getContentSize().width);
this->addChild(jinbian,6);
CCScale9Sprite *frame2 = CCScale9Sprite::createWithSpriteFrameName("barrack_kuang.png");
frame2->setPreferredSize(CCSizeMake(568+20, 320));
this->addChild(frame2,7);
frame2->setPosition(ccpAdd(jinbian->getPosition(), ccp(0, -frame2->getContentSize().height/2 - 30)));
CCSprite *frame2bg = CCSprite::createWithSpriteFrameName("barrack_kuangbg.png");
this->addChild(frame2bg,6);
frame2bg->setScaleX(590/frame2bg->getContentSize().width);
frame2bg->setScaleY(320/frame2bg->getContentSize().height);
frame2bg->setPosition(frame2->getPosition());
CCSprite *guang2l = CCSprite::createWithSpriteFrameName("barrack_kuang_guangl.png");
this->addChild(guang2l,6);
guang2l->setAnchorPoint(ccp(0, 1));
CCSprite *guang2r = CCSprite::createWithSpriteFrameName("barrack_kuang_guangl.png");
this->addChild(guang2r,6);
guang2r->setFlipX(true);
guang2r->setAnchorPoint(ccp(1, 1));
CCSprite *guang2m = CCSprite::createWithSpriteFrameName("barrack_kuang_guangm.png");
this->addChild(guang2m,6);
guang2m->setScaleX(468/guang2m->getContentSize().width);
guang2m->setAnchorPoint(ccp(0.5, 1));
guang2m->setPosition(ccpAdd(frame2->getPosition(), ccp(0, frame2->getContentSize().height*.5)));
guang2r->setPosition(ccpAdd(guang2m->getPosition(), ccp(284+10, 0)));
guang2l->setPosition(ccpAdd(guang2m->getPosition(), ccp(-284-10, 0)));
CCScale9Sprite *fontbg = CCScale9Sprite::createWithSpriteFrameName("box_fontbg.png");
fontbg->setPreferredSize(CCSizeMake(538, 205));
this->addChild(fontbg,6);
fontbg->setPosition(ccpAdd(frame2->getPosition(), ccp(0, 26)));
SGConsumableDataModel *temp = SGStaticDataManager::shareStatic()->getConsumableById(_card->getItemId());
SGCCLabelTTF* a = SGCCLabelTTF::create(temp->getConsumeDesc()->getCString(), FONT_BOXINFO, 28, CCSizeMake(504,400));
a->setAnchorPoint(ccp(0.5f, 1));
this->addChild(a,6);
a->setPosition(ccpAdd(fontbg->getPosition(), ccp(0, fontbg->getContentSize().height*.33)));
//setCardType,“强化合成“
SGConsumableDataModel *consumeData = SGStaticDataManager::shareStatic()->getConsumableById(_card->getItemId());
this->setCardType(consumeData->getConsumeType());
}
示例13: initContent
void GameSet::initContent()
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *colorlayer = CCLayerColor::create(ccc4(0, 0, 0, 120));
addChild(colorlayer);
colorlayer->setPosition(ccp(-winSize.width/2, -winSize.height/2));
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("common/common.plist");
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/gameSet/gameSet.plist");
CCSprite *bg = CCSprite::create("common/commonBg_451_305.png");
addChild(bg);
CCSprite *titleBg = CCSprite::createWithSpriteFrameName("common_titleBg.png");
bg->addChild(titleBg);
titleBg->setPosition(ccp(bg->getContentSize().width/2 + 50, bg->getContentSize().height));
CCLabelBMFont *title = CCLabelBMFont::create("设置", "font/font_uiTitle.fnt");
titleBg->addChild(title);
title->setPosition(ccp(titleBg->getContentSize().width/2 - 50, titleBg->getContentSize().height/2));
CCScale9Sprite *frame = CCScale9Sprite::create("common/common_scale_1.png");
frame->setPreferredSize(CCSizeMake(328, 150));
frame->setAnchorPoint(ccp(0.5, 0.5));
bg->addChild(frame);
frame->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 40));
// CCSprite *title = CCSprite::createWithSpriteFrameName("set_title.png");
// bg->addChild(title);
// title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 20));
CCControlButton *closeBtn = INSTANCE(ButtonUtils)->createButton("common_backBtn.png", CCSizeMake(75, 81), "");
bg->addChild(closeBtn);
closeBtn->setPosition(ccp(bg->getContentSize().width - 20, bg->getContentSize().height - 20));
closeBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::close), CCControlEventTouchUpInside);
CCLabelBMFont *musicLabel = CCLabelBMFont::create("音乐", "font/font_common.fnt");
bg->addChild(musicLabel);
musicLabel->setPosition(ccp(115, 235));
CCControlSlider *musicSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
musicSlider->setAnchorPoint(ccp(0.5f, 1.0f));
musicSlider->setMinimumValue(0.0f); // Sets the min value of range
musicSlider->setMaximumValue(1.0f); // Sets the max value of range
musicSlider->setTag(1);
musicSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::musicCallBack), CCControlEventValueChanged);
musicSlider->setPosition(ccp(260, 250));
musicSlider->setTouchPriority(0);
float musicVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_musicVolume, 0.5);
musicSlider->setValue(musicVolume);
bg->addChild(musicSlider);
CCLabelBMFont *soundLabel = CCLabelBMFont::create("音效", "font/font_common.fnt");
bg->addChild(soundLabel);
soundLabel->setPosition(ccp(115, 185));
CCControlSlider *soundSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
soundSlider->setAnchorPoint(ccp(0.5f, 1.0f));
soundSlider->setMinimumValue(0.0f); // Sets the min value of range
soundSlider->setMaximumValue(1.0f); // Sets the max value of range
soundSlider->setTag(1);
soundSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::soundCallBack), CCControlEventValueChanged);
soundSlider->setPosition(ccp(260, 200));
soundSlider->setTouchPriority(0);
float soundVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_soundVolume, 0.5);
soundSlider->setValue(soundVolume);
bg->addChild(soundSlider);
CCControlButton *btn1 = INSTANCE(ButtonUtils)->createButton("set_guide.png", CCSizeMake(84, 87), "");
CCControlButton *btn3 = INSTANCE(ButtonUtils)->createButton("set_contact.png", CCSizeMake(83, 84), "");
CCControlButton *btn4 = INSTANCE(ButtonUtils)->createButton("set_develep.png", CCSizeMake(83, 92), "");
bg->addChild(btn1);
bg->addChild(btn3);
bg->addChild(btn4);
if(showHelp){
wikiBtn = INSTANCE(ButtonUtils)->createButton("set_wiki.png", CCSizeMake(87, 89), "");
bg->addChild(wikiBtn);
btn1->setPosition(ccp(80, 50));
wikiBtn->setPosition(ccp(180, 50));
btn3->setPosition(ccp(280, 50));
btn4->setPosition(ccp(380, 50));
wikiBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn2Handler), CCControlEventTouchUpInside);
}else{
btn1->setPosition(ccp(80, 50));
btn3->setPosition(ccp(230, 50));
btn4->setPosition(ccp(380, 50));
}
btn1->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn1Handler), CCControlEventTouchUpInside);
btn3->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn3Handler), CCControlEventTouchUpInside);
btn4->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn4Handler), CCControlEventTouchUpInside);
//.........这里部分代码省略.........
示例14: tableCellAtIndex
CCTableViewCell* MailListScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCString *string = (CCString *)mArrayList->objectAtIndex(idx);
CCSize size = this->tableCellSizeForIndex(table, idx);
CCTableViewCell *cell = table->dequeueCell();
if (!cell) {
cell = new CCTableViewCell();
cell->autorelease();
CCSprite *sState = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_state_read.png"));
sState->setAnchorPoint(CCPointMake(0, 0.5));
sState->setPosition(ccp(10,size.height * 0.5));
sState->setTag(120);
cell->addChild(sState);
CCLabelTTF *lblName = CCLabelTTF::create(string->getCString(), "Arial", 14.0);
lblName->setPosition(ccp(65,size.height * 0.5));
lblName->setColor(ccc3(255, 255, 204));
//lblName->enableStroke(ccc3(51, 0, 0), 0.6);
lblName->setTag(121);
lblName->setHorizontalAlignment(kCCTextAlignmentLeft);
lblName->setString(string->getCString());
cell->addChild(lblName);
CCLabelTTF *lblSubject = CCLabelTTF::create("100", "Arial", 14.0);
lblSubject->setPosition(ccp(130,size.height * 0.5));
lblSubject->setColor(ccc3(255, 255, 204));
//lblSubject->enableStroke(ccc3(51, 0, 0), 0.6);
lblSubject->setTag(122);
lblSubject->setString(string->getCString());
cell->addChild(lblSubject);
CCScale9Sprite *sline = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_line.png"));
sline->setPreferredSize(CCSizeMake(310, 1));
sline->setPosition(ccp(0,size.height-2));
sline->setAnchorPoint(CCPointZero);
cell->addChild(sline);
CCMenu *menuCheck = this->generateCheckBox();
cell->addChild(menuCheck);
CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
toggle->setUserData(&vUserData[idx]);
if (vUserData[idx] == 1) {
toggle->setSelectedIndex(1);
} else {
toggle->setSelectedIndex(0);
}
menuCheck->setTag(123);
menuCheck->setAnchorPoint(CCPointMake(0, 0.5));
menuCheck->setPosition(CCPointMake(280, size.height * 0.5));
}
else
{
CCLabelTTF *lblName = (CCLabelTTF*)cell->getChildByTag(121);
lblName->setString(string->getCString());
CCLabelTTF *lblSubject = (CCLabelTTF*)cell->getChildByTag(122);
lblSubject->setString(string->getCString());
CCMenu *menuCheck = (CCMenu *)cell->getChildByTag(123);
CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
toggle->setUserData(&vUserData[idx]);
if (vUserData[idx] == 1) {
toggle->setSelectedIndex(1);
} else {
toggle->setSelectedIndex(0);
}
}
return cell;
}