本文整理汇总了C++中BaseSprite::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite::setScale方法的具体用法?C++ BaseSprite::setScale怎么用?C++ BaseSprite::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseSprite
的用法示例。
在下文中一共展示了BaseSprite::setScale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
void ZhuangbeiXilianOverOption::onEnter()
{
CCSprite::onEnter();
if (m_nLevel != -1)
{
BaseSprite *bgSpr = BaseSprite::create("zhuangbei_xiangxi_xilian_shuxing.png");
addChild(bgSpr);
this->setContentSize(bgSpr->getContentSize());
BaseSprite *xingxingImg = BaseSprite::create(CCString::createWithFormat("gongming_anniu_%d.png",m_nLevel)->getCString());
bgSpr->addChild(xingxingImg);
xingxingImg->setPosition(ccp(40, bgSpr->getContentSize().height / 2));
xingxingImg->setScale(0.58f);
ZBAttr zb_attr;
zb_attr.attr_type = m_nAtter_type_index;
zb_attr.attr_value = m_nPercent;
string attrStr = GetMoFaShuXing_ByZBAttr(zb_attr, true);
CCLabelTTF *label = CCLabelTTF::create(attrStr.c_str(), fontStr_kaiti, 20);
bgSpr->addChild(label);
label->setColor(ccc3(255,255,255));
label->setPosition(ccp(bgSpr->getContentSize().width / 2, bgSpr->getContentSize().height / 2));
bgSpr->setPosition(ccp(bgSpr->getContentSize().width / 2,bgSpr->getContentSize().height / 2));
if (m_bIsBiger)
{
CCSprite *spr = CCSprite::create("renxing_zhuangbeitisheng.png");
spr->setPosition(ccp(230,this->getContentSize().height / 2));
bgSpr->addChild(spr);
}
if (m_bIsFirst)
{
CCSprite *spr = CCSprite::create("zhuangbei_xiangxi_xilian_shuxing_xiaoguo.png");
spr->setPosition(ccp(this->getContentSize().width / 2,this->getContentSize().height / 2));
bgSpr->addChild(spr);
float time = 0;
float minTime = 0.5f;
float maxTime = 1.2f;
time = CCRANDOM_0_1()*(maxTime - minTime) + minTime;
Blink(spr,time);
}
}
else
{
BaseSprite *xingxingImg = BaseSprite::create("zhuangbei_xiangxi_xilian_shuxing_suoding.png");
addChild(xingxingImg);
xingxingImg->setPosition(ccp(xingxingImg->getContentSize().width / 2,xingxingImg->getContentSize().height / 2));
this->setContentSize(xingxingImg->getContentSize());
}
}
示例2: CCSize
GetAwardLayer::GetAwardLayer(CCString info, vector<ItemInfo> items, vector<Flat_DuanzaoGroupZBInfo> equips)
{
CCLayerColor::initWithColor(ccc4(0,0,0,255));
CCSize visSize = CCDirector::sharedDirector()->getWinSize();
mBoard = BaseSprite::create("shangpin_goumai_tishikuang.png");
addChild(mBoard);
mBoard->setPosition(ccp(visSize.width/2, visSize.height/2));
//label 提示
{
CCLabelTTF* label = CCLabelTTF::create(info.getCString(),
fontStr_kaiti, 20, CCSize(425, 0), kCCTextAlignmentLeft);
label->setColor(ccWHITE);
mBoard->addChild(label, 1);
if (items.size() == 0 && equips.size() == 0)
{
label->setAnchorPoint(ccp(0.5, 0.5));
label->setPosition(ccp(mBoard->getContentSize().width/2, 222));
}
else
{
label->setAnchorPoint(ccp(0.5, 1));
label->setPosition(ccp(mBoard->getContentSize().width/2, 326));
}
}
//材料
int label_size = 20;
ccColor3B label_color = ccWHITE;
int allNum = items.size() + equips.size();
int posIdx = 0;
for (int i=0; i < items.size(); ++i, ++posIdx)
{
BaseSprite* cailiaoImg = BaseSprite::create("daoju_kuang_bg.png");
mBoard->addChild(cailiaoImg);
int pos_x = mBoard->getContentSize().width/2;
int delta = posIdx - allNum/2;
if(allNum % 2 == 0)
{
float del = delta + 0.5;
pos_x += del * (cailiaoImg->getContentSize().width + 10);
}
else
{
pos_x += delta * (cailiaoImg->getContentSize().width + 10);
}
cailiaoImg->setPosition(ccp(pos_x, mBoard->getContentSize().height/2+24));
//item img
BaseSprite * itemImg = BaseSprite::create(
ImageManager::getManager()->getItemFilename(items.at(i).type)); // .count .type
cailiaoImg->addChild(itemImg);
itemImg->setPosition(ccp(cailiaoImg->getContentSize().width/2, cailiaoImg->getContentSize().height/2));
//数量
char buf[20];
sprintf(buf, "\nx%u", items.at(i).count);
string temp = CS::getItemName(items.at(i).type);
temp += buf;
CCLabelTTF *labelShuliang = CCLabelTTF::create(temp.c_str(), fontStr_kaiti, label_size
, CCSize(0,0), kCCTextAlignmentCenter);
cailiaoImg->addChild(labelShuliang);
labelShuliang->setPosition(ccp(cailiaoImg->getContentSize().width/2, -labelShuliang->getContentSize().height/2));
labelShuliang->setColor(label_color);
}
for (int i=0; i<equips.size(); ++i, ++posIdx)
{
BaseSprite* diwenImg = BaseSprite::create(
ImageManager::getManager()->getImageData_DiWen_WithBianKuang(equips.at(i).zhuangbei_colour)); // .count .type
mBoard->addChild(diwenImg);
int pos_x = mBoard->getContentSize().width/2;
int delta = posIdx - allNum/2;
if(allNum % 2 == 0)
{
float del = delta + 0.5;
pos_x += del * (diwenImg->getContentSize().width + 10);
}
else
{
pos_x += delta * (diwenImg->getContentSize().width + 10);
}
diwenImg->setPosition(ccp(pos_x, mBoard->getContentSize().height/2+24));
//equip pic
string equipfile = equips.at(i).zhuangbei_pic;
equipfile = "minute_" + equipfile + ".png";
BaseSprite *s = BaseSprite::create(equipfile);
diwenImg->addChild(s);
s->setScale(0.23f);
s->setPosition(ccp(diwenImg->getContentSize().width/2,diwenImg->getContentSize().height/2));
//数量
char buf[20];
sprintf(buf, "\nx%d", 1);
string temp = equips.at(i).zhuangbei_name;
temp += buf;
CCLabelTTF *labelShuliang = CCLabelTTF::create(temp.c_str(), fontStr_kaiti, label_size
//.........这里部分代码省略.........
示例3: getItemContentByIndex
BaseSprite* MainLayerZhuangBeiBaseBody::getItemContentByIndex(unsigned int index)
{
BaseSprite* bg = BaseSprite::create("mianban_zhuangbei_xiangxi.png");
CCString tempStr;
CCPoint picPos = ccp(75.0f, bg->getContentSize().height/2);
{
ImageData diWenData = ImageManager::getManager()->getImageData_DiWen_List(
mEquipmentVec[index]->getEquipColor(),
false,
mEquipmentVec[index]->isPartOfSuit(),
mEquipmentVec[index]->haveZhuanke());
BaseSprite* diWen = BaseSprite::create(diWenData.getCurrentImageFile());
diWen->setScale(diWenData.scale);
diWen->setPosition(picPos);
bg->addChild(diWen,0,TAG_BaseBody_TABLE_ITEM_DiWen);
{
BaseSprite *sprite = ImageManager::getManager()->getSpriteOfZhuangbei(mEquipmentVec[index],true,true);
//sprite->setScale(data.scale);
sprite->setScale(0.43f);
sprite->setPosition(picPos);
bg->addChild(sprite,0,TAG_BaseBody_TABLE_ITEM_Image);
}
//封印
if (mEquipmentVec[index]->isInFengYin())
{
BaseSprite *fyImg = BaseSprite::create("shenbing_fengyin_suo.png");
bg->addChild(fyImg, 0, TAG_BaseBody_TABLE_FengYin_Img);
fyImg->setPosition(diWen->getPosition());
fyImg->setScale(diWen->getContentSize().width*diWen->getScale() / fyImg->getContentSize().width);
}
}
// 添加图片识别区
{
ImageData selecedData = ImageManager::getManager()->getImageData_DiWen_Selected(
mEquipmentVec[index]->getEquipColor(),
false,//mEquipmentVec[index]->isShenBing(),
mEquipmentVec[index]->isPartOfSuit());
BaseSprite* menuItemSel = BaseSprite::create(selecedData.getCurrentImageFile());
menuItemSel->setScale(selecedData.scale);
CCSprite* menuRect = CCSprite::createWithTexture(menuItemSel->getTexture());
menuRect->setScale(0.0f);
FXScrollMenu *menu = FXScrollMenu::create(
mTableView->getParent()->convertToWorldSpace(mTableView->getPosition()), mTableView->getViewSize());
bg->addChild(menu, 0, TAG_BaseBody_MENU);
menu->setPosition(ccp(0,0));
CCMenuItemSprite* t = CCMenuItemSprite::create(menuRect,menuItemSel,this,SEL_MenuHandler(&MainLayerZhuangBeiBaseBody::itemImageClicked));
menu->addChild(t, 0, index);
t->setPosition(picPos);
}
float left_x_start = 160 - 4;
//名称
{
CCLabelTTF* label;
char str[64];
if (mEquipmentVec[index]->getEquipData().qianghua_data.qianghua_count != 0)
{
sprintf(str, "%s", mEquipmentVec[index]->getName().c_str());
}
else
{
sprintf(str, "%s", mEquipmentVec[index]->getName().c_str());
}
label = LF::lable(bg,str,ccp(left_x_start,190),24,fontStr_kaiti);
label->setTag(TAG_BaseBody_LABLE_NAME);
ccColor3B color = ImageManager::getManager()->getShowColor(mEquipmentVec[index]->getEquipColor(),false,mEquipmentVec[index]->isPartOfSuit());
label->setColor(color);
}
//类型
{
std::string typeStr =
CS::getZhuangbeiTypeName(mEquipmentVec[index]->getType(), mEquipmentVec[index]->getEquipColor());
CCLabelTTF* label;
label = LF::lable(bg,typeStr,ccp(left_x_start,165),18,fontStr_kaiti);
label->setTag(TAG_BaseBody_LABLE_TYPE);
label->setColor(fonColor_CiYao);
}
//白字
{
CCLabelTTF* label_baizhi = NULL;
bool hasBaiZhi = false;
{
float baizi = 0;
switch(mEquipmentVec[index]->getType())
{
case ZhuangbeiType_DanshouJian:
case ZhuangbeiType_ShuangshouBishou:
case ZhuangbeiType_ShuangshouFu:
//.........这里部分代码省略.........
示例4: clickShuoming
void ZhuangbeiXilianUI::clickShuoming(CCObject *obj)
{
//弹框
BaseSprite* dialog = BaseSprite::create("shangpin_goumai_tishikuang.png");
dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2));
//确认 取消按键
CCMenu* menu = CCMenu::create();
menu->setPosition(CCPointZero);
{
//返回
CCMenuItemImage *fanhui = CCMenuItemImage::create(
"shuxing_renwu_fanhui.png"
, "shuxing_renwu_fanhui_select.png"
, this, menu_selector(ZhuangbeiXilianUI::menuItemClicked_ShuoMingMenu));
menu->addChild(fanhui, 1, 20);
fanhui->setPosition(ccp(dialog->getContentSize().width/2,70));
}
//content
{
CCSize size = dialog->getContentSize();
//title
CCLabelTTF *titleLabel = CCLabelTTF::create(LFStrings::getValue("XilianTitle").c_str(), fontStr_kaiti, 20);
titleLabel->setHorizontalAlignment(kCCTextAlignmentCenter);
dialog->addChild(titleLabel);
titleLabel->setAnchorPoint(ccp(0.5,1));
titleLabel->setPosition(ccp(size.width/2, size.height-56));
CCLabelTTF *shuoMingLabel = CCLabelTTF::create(LFStrings::getValue("XilianInfo").c_str(), fontStr_kaiti, 20 );
shuoMingLabel->setHorizontalAlignment(kCCTextAlignmentRight);
dialog->addChild(shuoMingLabel);
shuoMingLabel->setColor(fonColor_PuTong);
shuoMingLabel->setAnchorPoint(ccp(0.5,1));
shuoMingLabel->setPosition(ccp(size.width/2, size.height-110));
CCPoint pos = shuoMingLabel->getPosition();
pos.x += shuoMingLabel->getContentSize().width / 2 - 45;
pos.y += 5;
int side_y = 20;
for (int i = 0 ; i < 4 ; i ++)
{
BaseSprite *xingxingImg = BaseSprite::create(CCString::createWithFormat("gongming_anniu_%d.png",i + 1)->getCString());
dialog->addChild(xingxingImg);
CCPoint point;
point.x = pos.x - xingxingImg->getContentSize().width / 2 * 0.38f;
point.y = pos.y - i * side_y - xingxingImg->getContentSize().height / 2 * 0.38f;
xingxingImg->setPosition(point);
xingxingImg->setScale(0.38f);
}
}
//
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setTag(Tag_Board_ShuoMing);
lfAlert->setBaseContainer(dialog,menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128, Tag_Board_ShuoMing);
lfAlert->release();
}
}
示例5: getSpriteOfZhuangbei
//.........这里部分代码省略.........
{
BaseSprite* imageStar = NULL;
if (i < qinghua.qianghua_count)
{
switch (qinghua.info_arr[i].level)
{
case 4:
case QianghuaLevel_jin_special:
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_jin.png");
break;
case 3:
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_yin.png");
break;
case 2:
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_tong.png");
break;
case 1:
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_tie.png");
break;
default:
CCLog("Error : %s --> qiangjhua_level = %d",__FUNCTION__,qinghua.info_arr[i].level);
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_tie.png");
CCAssert(false,"未知的level");
}
}
else
{
imageStar = BaseSprite::create("gongjiang_qianghua_jieguo_kong.png");
}
sprite->addChild(imageStar);
imageStar->setPosition(ccp(posX,posY));
imageStar->setScale(scale);
posX += temp->getContentSize().width * imageStar->getScaleX() - 8;
}
}
if(holdNum == 1)
{
hole1 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole1);
hole1->setPosition(ccp(sprite->getContentSize().width/2, sprite->getContentSize().height/2));
}
else if(holdNum == 2)
{
hole1 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole1);
hole1->setPosition(ccp(sprite->getContentSize().width/2, sprite->getContentSize().height*3.3f/5));
hole2 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole2);
hole2->setPosition(ccp(sprite->getContentSize().width/2, sprite->getContentSize().height*1.7f/5));
}
else if(holdNum == 3)
{
hole1 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole1);
hole1->setPosition(ccp(sprite->getContentSize().width/2, sprite->getContentSize().height*3.5f/5));
hole2 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole2);
hole2->setPosition(ccp(sprite->getContentSize().width/2, sprite->getContentSize().height* 1.0f/2.0f));
hole3 = BaseSprite::create("zhuangbei_kong.png");
sprite->addChild(hole3);
示例6: displayXiangQing
void MailInfoListLayer::displayXiangQing(Flat_DuanzaoGroupZBInfo zbInfo)
{
//this->disableAllTouchBegin();
mCurTaoZhuang_Info = zbInfo;
BaseSprite *board = BaseSprite::create("zhuangbei_xiangxi_mianban.png");
/*BaseLayer *layer = new BaseLayer();
layer->setContentSize(board->getContentSize());
layer->setPosition(board->getPosition());
layer->addChild(board);*/
CCDirector::sharedDirector()->getRunningScene()->addChild(board,1030);
//MainLayerBase::getCurrentMainBase()->getHeader()->setContent(BaseSprite::create());
//MainLayerBase::getCurrentMainBase()->setContaintLayer(layer,false);
//layer->release();
refreshEquipBoard(board, zbInfo);
board->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 + 106));
ListMenu *menu = ListMenu::create();
board->addChild(menu, 10);
menu->setPosition(CCPointZero);
// menu->setTouchPriority(-131);
BaseSprite *norImg = BaseSprite::create("close.png");
BaseSprite *selImg = BaseSprite::create("close_select.png");
CCMenuItemSprite *item = CCMenuItemSprite::create(norImg, selImg, NULL, this, menu_selector(MailInfoListLayer::menuItemClicked_close));
menu->addChild(item, 0);
item->setPosition(ccp(board->getContentSize().width-44+12, board->getContentSize().height-36+2));
//底纹
ImageData diWenData = ImageManager::getManager()->getImageData_DiWen_XiangQing(
zbInfo.zhuangbei_colour
, false
, SuitPool::getPool()->isSuit(zbInfo.zb_group_id));
BaseSprite* diWen = BaseSprite::create(diWenData.getCurrentImageFile());
diWen->setScale(0.7f);
board->addChild(diWen);
diWen->setPosition(ccp(123, 838-240+122));
// 装备图片
string equipfile = zbInfo.zhuangbei_pic;
equipfile = "minute_" + equipfile + ".png";
BaseSprite *s = BaseSprite::create(equipfile);
diWen->addChild(s);
s->setPosition(ccp(diWen->getContentSize().width/2,diWen->getContentSize().height/2));
//套装按钮
if(SuitPool::getPool()->isSuit(zbInfo.zb_group_id))
{
string norStr = "zhuangbei_xiangxi_mianban_anniu_taozhuang.png";
string selStr = "zhuangbei_xiangxi_mianban_anniu_taozhuang_select.png";
// if (ChuanqiPool::getPool()->isShenBing(mEquipVec.at(idx).zb_group_id))
// {
// norStr = "zhuangbei_xiangxi_mianban_anniu_taozhuang_shenbing.png";
// selStr = "zhuangbei_xiangxi_mianban_anniu_taozhuang_shenbing_select.png";
// }
CCMenuItemImage *taozhuangItem = CCMenuItemImage::create(
norStr.c_str()
, selStr.c_str()
, this ,menu_selector(MailInfoListLayer::menuItemClicked_equipDetailMenu));
menu->addChild(taozhuangItem, 0);
taozhuangItem->setAnchorPoint(ccp(1, 0));
taozhuangItem->setPosition(ccp(diWen->getPositionX()+diWen->getContentSize().width/2*diWen->getScaleX()
, diWen->getPositionY()-diWen->getContentSize().height/2*diWen->getScaleY()));
taozhuangItem->setEnabled(false);
}
m_dEquimentDialog = board;
m_mDEquipmentMenu = menu;
}
示例7: initBSandMagic
void SpriteSystem::initBSandMagic()
{
//初始化人物
struct _stHeroConf
{
float spScale[3];//缩放
Point spPosStart[3];//起始位置
Point spPosEnd[3];//结束位置
bool spFlip[3];//是否翻转,英雄翻转,敌人不翻转,面对面
_stHeroConf()
{
spScale[0] = 1.5f; spScale[1] = 1.5f; spScale[2] = 1.5f;
spFlip[0] = true; spFlip[1] = true; spFlip[2] = true;
spPosStart[0] = PointS_1; spPosStart[1] = PointS_2; spPosStart[2] = PointS_3;
spPosEnd[0] = PointE_1; spPosEnd[1] = PointE_2; spPosEnd[2] = PointE_3;
}
}_stHeroConf;
struct _stEnemyConf
{
float spScale[3];//缩放
Point spPosStart[3];//起始位置
Point spPosEnd[3];//结束位置
bool spFlip[3];//是否翻转,英雄翻转,敌人不翻转,面对面
_stEnemyConf()
{
spScale[0] = 1.5f; spScale[1] = 1.5f; spScale[2] = 1.5f;
spFlip[0] = false; spFlip[1] = false; spFlip[2] = false;
spPosStart[0] = PointS_4; spPosStart[1] = PointS_5; spPosStart[2] = PointS_6;
spPosEnd[0] = PointE_4; spPosEnd[1] = PointE_5; spPosEnd[2] = PointE_6;
}
}_stEnemyConf;
//初始化英雄和敌人
for (unsigned int i = 0; i < 3; i++)
{
BaseSprite* hero = BaseSprite::create(m_bsConf[i]);
hero->setScale(_stHeroConf.spScale[i]);
hero->setPosition(_stHeroConf.spPosStart[i]);
hero->setFlippedX(_stHeroConf.spFlip[i]);
hero->startAction(SPRITESTATE_IDLE);
hero->move(MoveType_To, _stHeroConf.spPosEnd[i], 4.5f);//执行完有回调
addChild(hero,1);
//加入向量
m_vHeros.pushBack(hero);
BaseSprite* enemy = BaseSprite::create(m_bsConf[i+3]);
enemy->setScale(_stEnemyConf.spScale[i]);
enemy->setPosition(_stEnemyConf.spPosStart[i]);
enemy->setFlippedX(_stEnemyConf.spFlip[i]);
enemy->startAction(SPRITESTATE_IDLE);
enemy->move(MoveType_To, _stEnemyConf.spPosEnd[i], 4.5f);//执行完有回调
addChild(enemy,1);
//加入向量
m_vEnemys.pushBack(enemy);
Node* node = Node::create();
Sprite* lifebg = Sprite::create(s_ptBg);//背景
m_ptLifeTop[i] = ProgressTimer::create(Sprite::create(s_ptLife2));//进度条
m_ptLifeTop[i]->setType(ProgressTimer::Type::BAR);//条形
m_ptLifeTop[i]->setMidpoint(Point::ANCHOR_MIDDLE_LEFT);//(0,0.5)锚点为增长原点
m_ptLifeTop[i]->setBarChangeRate(Point::ANCHOR_MIDDLE_RIGHT);//向(1,0.5)增长
m_ptLifeTop[i]->setPercentage(100);
node->setPosition(enemy->getContentSize().width/2,enemy->getContentSize().height*0.8);
enemy->addChild(node);
node->addChild(lifebg, 0);
node->addChild(m_ptLifeTop[i], 1);
node->setScale(0.8);
//添加敌人生命值
}
setAttackTarget();//设置攻击目标
// //初始化技能、远程攻击 --》不能这样,因为多个英雄释放同一种技能时,会重复addChild
// for(int i = 0; i < 5; i++)
// {
// Magic* magic = Magic::create(m_magConf[i]);
// m_vMagics.pushBack(magic);//这里会retain一下
// }
scheduleUpdate();
}