本文整理汇总了C++中Scale9Sprite::setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Scale9Sprite::setPreferredSize方法的具体用法?C++ Scale9Sprite::setPreferredSize怎么用?C++ Scale9Sprite::setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scale9Sprite
的用法示例。
在下文中一共展示了Scale9Sprite::setPreferredSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tableCellAtIndex
TableViewCell* SkillTableView::tableCellAtIndex(TableView *table, ssize_t idx)
{
CCString* str = CCString::createWithFormat("ui/skill/skill_%d.png",2001 + (int)idx);
TableViewCell* cell = table->dequeueCell();
if (!cell)
{
cell = new TableViewCell();
cell->autorelease();
Scale9Sprite* bg = Scale9Sprite::create("ui/cell.png");
bg->setAnchorPoint(Point::ZERO);
bg->setPosition(Point::ZERO);
bg->setPreferredSize(Size(420, 80));
cell->addChild(bg);
Sprite* skill = Sprite::create(str->getCString());
skill->setPosition(Point(50, 40));
cell->addChild(skill, 0, 123);
m_skillVec.push_back(skill);
}
else
{
Sprite* skill = (Sprite*)cell->getChildByTag(123);
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(str->getCString());
skill->setTexture(texture);
}
cell->setTag(2001+(int)idx);
return cell;
}
示例2: semiselected
void PubSprite::semiselected()
{
if (pub_sprite_ == NULL)
return;
const float kDisplayWidth = 354.0 * gScale;
const float kDisplayHeight = 530.0 * gScale;
Rect inset_rect = CCRectMake(38, 29, 1, 1);
Rect full_rect = CCRectMake(0, 0, 74, 284);
pub_sprite_->removeAllChildren();
/* add the sun state */
Sprite *sun = Sprite::create("main_screen/sun_semi.png");
const float kSunOffsetY = 317;
if (gScale == 1.0)
sun->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kSunOffsetY));
else
sun->setPosition(ccp(kDisplayWidth, kDisplayHeight+kSunOffsetY));
sun->setTag(2);
pub_sprite_->addChild(sun, 1);
/* add the white border*/
const float kBorderWidth = 480;
const float kBorderHeight = 706;
const float kBorderX = 226;
const float kBorderY = 336;
Scale9Sprite *yborder = Scale9Sprite::create("main_screen/border_selected.png", full_rect, inset_rect);
yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
yborder->setPosition(ccp(kBorderX, kBorderY));
yborder->setTag(2);
pub_sprite_->addChild(yborder);
}
示例3: unseleted
void PubSprite::unseleted()
{
if (pub_sprite_ == NULL)
return;
const float kDisplayWidth = 354.0 * gScale;
const float kDisplayHeight = 530.0 * gScale;
Rect inset_rect = CCRectMake(11, 13, 1, 1);
Rect full_rect = CCRectMake(0, 0, 22, 23);
pub_sprite_->removeAllChildren();
/* add the cloud state */
Sprite *cloud = Sprite::create("main_screen/cloud_unselected.png");
const float kCloudOffsetY = 317;
if (gScale == 1.0)
cloud->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kCloudOffsetY));
else
cloud->setPosition(ccp(kDisplayWidth, kDisplayHeight+kCloudOffsetY));
cloud->setTag(1);
pub_sprite_->addChild(cloud, 1);
/* add the white border*/
const float kBorderWidth = 460;
const float kBorderHeight = 685;
const float kBorderX = 226;
const float kBorderY = 336;
Scale9Sprite *wborder = Scale9Sprite::create("main_screen/border_unselected.png", full_rect, inset_rect);
wborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
wborder->setPosition(ccp(kBorderX, kBorderY));
wborder->setTag(1);
pub_sprite_->addChild(wborder);
}
示例4: selected
void PubSprite::selected()
{
if (pub_sprite_ == NULL)
return;
const float kDisplayWidth = 354.0 * gScale;
const float kDisplayHeight = 530.0 * gScale;
Rect inset_rect = CCRectMake(38, 29, 1, 1);
Rect full_rect = CCRectMake(0, 0, 74, 284);
pub_sprite_->removeAllChildren();
/**
* add the sun state
*/
Sprite *sun = Sprite::create("main_screen/sun_selected.png");
/* gScale is 1 means 1080p, so 2/3 is a fixed number to get the right position */
const float kSunOffsetY = 317;
if (gScale == 1.0)
sun->setPosition(ccp(kDisplayWidth*2/3, kDisplayHeight*2/3+kSunOffsetY));
else
sun->setPosition(ccp(kDisplayWidth, kDisplayHeight+kSunOffsetY));
sun->setTag(2);
pub_sprite_->addChild(sun, 1);
/**
* add the white border
*/
const float kBorderWidth = 480;
const float kBorderHeight = 706;
const float kBorderX = 226;
const float kBorderY = 336;
Scale9Sprite *yborder = Scale9Sprite::create("main_screen/border_selected.png", full_rect, inset_rect);
yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
yborder->setPosition(ccp(kBorderX, kBorderY));
yborder->setTag(2);
pub_sprite_->addChild(yborder);
if (pub_title_ != NULL){
int size = 36;
if (strlen(pub_title_) > 35){
size = 32;
}
LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
CCLog("title %s, length %d", pub_title_, strlen(pub_title_));
title->setFontFillColor(ccc3(255, 255, 0));
pub_sprite_->addChild(title);
const float kTitleOffsetX = 10;
const float kTitleOffsetY = 60;
if (gScale == 1.0)
title->setPosition(kDisplayWidth*2/3-kTitleOffsetX, kTitleOffsetY);
else
title->setPosition(kDisplayWidth-kTitleOffsetX, kTitleOffsetY);
}
}
示例5: showpubUnselect
void PubSprite::showpubUnselect()
{
pub_sprite_->removeAllChildren();
const float kDisplayWidth = 290.0 * gScale;
const float kDisplayHeight = 544.0 * gScale;
Rect inset_rect = CCRectMake(12, 12, 1, 1);
Rect full_rect = CCRectMake(0, 0, 23, 73);
/* add the cloud state */
Sprite *cloud = Sprite::create("main_screen/cloud_unselected.png");
const float kCloudOffsetY = 295;
const float kCloudOffsetX = 55;
if (gScale == 1.0)
cloud->setPosition(ccp(kDisplayWidth*2/3+kCloudOffsetX, kDisplayHeight*2/3+kCloudOffsetY));
else
cloud->setPosition(ccp(kDisplayWidth+kCloudOffsetX, kDisplayHeight+kCloudOffsetY));
cloud->setTag(1);
pub_sprite_->addChild(cloud, 1);
/**
* add the white border
*/
const float kBorderWidth = 460;
const float kBorderHeight = 730;
const float kBorderX = 225;
const float kBorderY = 310;
Scale9Sprite *wborder = Scale9Sprite::create("showlist/border_unselected.png", full_rect, inset_rect);
wborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
wborder->setPosition(ccp(kBorderX, kBorderY));
wborder->setTag(2);
pub_sprite_->addChild(wborder);
if (pub_title_ != NULL){
int size = 36;
if (strlen(pub_title_) > 30){
size = 32;
}
LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
/** the color is blue */
title->setFontFillColor(ccc3(67, 155, 203));
pub_sprite_->addChild(title);
const float kTitleOffsetX = 20;
const float kTitleOffsetY = 20;
if (gScale == 1.0)
title->setPosition(kDisplayWidth*2/3+kTitleOffsetX, -kTitleOffsetY);
else
title->setPosition(kDisplayWidth+kTitleOffsetX, -kTitleOffsetY);
}
}
示例6: setPreferredSize
void ControlButton::setPreferredSize(Size size)
{
if(size.width == 0 && size.height == 0)
{
_doesAdjustBackgroundImage = true;
}
else
{
_doesAdjustBackgroundImage = false;
DictElement * item = NULL;
CCDICT_FOREACH(_backgroundSpriteDispatchTable, item)
{
Scale9Sprite* sprite = static_cast<Scale9Sprite*>(item->getObject());
sprite->setPreferredSize(size);
}
}
示例7: showpubSelect
void PubSprite::showpubSelect()
{
pub_sprite_->removeAllChildren();
const float kDisplayWidth = 290.0 * gScale;
const float kDisplayHeight = 544.0 * gScale;
Sprite *sun = Sprite::create("main_screen/sun_semi.png");
const float kSunOffsetY = 315;
const float kSunOffsetX = 35;
if (gScale == 1.0)
sun->setPosition(ccp(kDisplayWidth*2/3+kSunOffsetX, kDisplayHeight*2/3+kSunOffsetY));
else
sun->setPosition(ccp(kDisplayWidth+kSunOffsetX, kDisplayHeight+kSunOffsetY));
sun->setTag(2);
pub_sprite_->addChild(sun, 1);
Rect inset_rect = CCRectMake(30, 27, 1, 1);
Rect full_rect = CCRectMake(0, 0, 60, 120);
const float kBorderWidth = 500;
const float kBorderHeight = 775;
const float kBorderX = 225;
const float kBorderY = 298;
Scale9Sprite *yborder = Scale9Sprite::create("showlist/border_selected.png", full_rect, inset_rect);
yborder->setPreferredSize(CCSizeMake(kBorderWidth, kBorderHeight));
yborder->setPosition(ccp(kBorderX, kBorderY));
yborder->setTag(2);
pub_sprite_->addChild(yborder);
if (pub_title_ != NULL){
int size = 46;
if (strlen(pub_title_) > 38){
size = 32;
}
LabelTTF *title= LabelTTF::create(pub_title_, "Arial", size);
/** the color is blue */
title->setFontFillColor(ccc3(67, 155, 203));
pub_sprite_->addChild(title);
const float kTitleOffsetX = 20;
const float kTitleOffsetY = 30;
if (gScale == 1.0)
title->setPosition(kDisplayWidth*2/3+kTitleOffsetX, -kTitleOffsetY);
else
title->setPosition(kDisplayWidth+kTitleOffsetX, -kTitleOffsetY);
}
}