本文整理汇总了C++中CAImageView::setCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ CAImageView::setCenter方法的具体用法?C++ CAImageView::setCenter怎么用?C++ CAImageView::setCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAImageView
的用法示例。
在下文中一共展示了CAImageView::setCenter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toast
void UtilManager::toast(string text, string image, bool isSmall) {
CAApplication::getApplication()->getRootWindow()->removeSubviewByTag(TOAST_VIEW_TAG);
CCSize winSize = CAApplication::getApplication()->getWinSize();
CAImageView *back = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.55, _px(120), _px(120)));
}
else {
back->setCenter(CCRect(winSize.width*0.5, winSize.height*0.4, _px(120), _px(120)));
}
back->setTag(TOAST_VIEW_TAG);
back->setImage(CAImage::create("image/scape_storage.png"));
//back->setColor(ccc4(31, 31, 31, 200));//40
CALabel *title = CALabel::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),
_dip(back->getBounds().size.height*0.8), 100, 100));
//title->setText(UTF8ToGBK::transferToGbk(text));
//title->setFontName(getChineseFont());
title->setColor(CAColor_white);
title->setTextAlignment(CATextAlignmentCenter);
title->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
title->setFontSize(_px(22));
back->addSubview(title);
CAImageView *icon = CAImageView::create();
if (isSmall == false) {
//CAView *back = CAView::createWithCenter(CCRect(winSize.width*0.5, winSize.height*0.5, _dip(winSize.width)*0.3, _dip(winSize.height)*0.3));
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 90 / 1.5, 68 / 1.5));
}
else {
icon->setCenter(CADipRect(_dip(back->getBounds().size.width*0.5), _dip(back->getBounds().size.height*0.4), 72 / 1.5, 72 / 1.5));
}
//CAImageView *icon = CAImageView::createWithCenter(CADipRect(_dip(back->getBounds().size.width*0.5),_dip(back->getBounds().size.height*0.4), 105/1.5, 95/1.5));
icon->setImage(CAImage::create(image));
back->addSubview(icon);
CAApplication::getApplication()->getRootWindow()->addSubview(back);
//CCLog("%s", get_date_now().c_str());
icon->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME / 2.0)));
back->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(0.3), CCFadeOut::create(TOAST_TIME)));
scheduleOnce(schedule_selector(UtilManager::removeToast), this, TOAST_TIME);
}
示例2: createWithCenter
CAImageView* CAImageView::createWithCenter(const CCRect& rect)
{
CAImageView * pRet = new CAImageView();
if (pRet && pRet->init())
{
pRet->setCenter(rect);
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
示例3: setMarginImageRight
void CATextField::setMarginImageRight(const DSize& imgSize, const std::string& filePath)
{
setMarginRight(imgSize.width);
CAImageView* ima = (CAImageView*)this->getSubviewByTag(1011);
if (!ima)
{
ima = CAImageView::create();
ima->setTag(1011);
this->addSubview(ima);
}
ima->setCenter(DRect(getBounds().size.width - imgSize.width / 2, getBounds().size.height / 2, imgSize.width, imgSize.height));
ima->setImage(CAImage::create(filePath));
}
示例4: copy
CAView* CAImageView::copy()
{
CAImageView* pReturn = CAImageView::create();
if (m_bFrame)
{
pReturn->setFrame(this->getFrame());
}
else
{
pReturn->setCenter(this->getCenter());
}
pReturn->setImageViewScaleType(this->getImageViewScaleType());
pReturn->setImage(this->getImage());
pReturn->setColor(this->getColor());
return pReturn;
}
示例5: viewDidLoad
void ImageViewTest::viewDidLoad()
{
size = this->getView()->getBounds().size;
CALabel* originalImage = CALabel::createWithCenter(CADipRect(size.width*0.5, size.height*0.1, size.width*0.4, 50 * CROSSAPP_ADPTATION_RATIO));
originalImage->setText("Original image");
originalImage->setFontSize(_px(30));
originalImage->setColor(ccc4(51, 204, 255, 255));
originalImage->setTextAlignment(CATextAlignmentCenter);
originalImage->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->getView()->addSubview(originalImage);
CAImageView* firstImage = CAImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_normal.png"));
firstImage->setCenter(CADipRect(size.width*0.2, size.height*0.15,32,32));
this->getView()->addSubview(firstImage);
CAImageView* secondImage = CAImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png"));
secondImage->setCenter(CADipRect(size.width*0.5, size.height*0.15,32, 32));
this->getView()->addSubview(secondImage);
CAImageView* thirdImage = CAImageView::createWithImage(CAImage::create("source_material/slider_indicator.png"));
thirdImage->setCenter(CADipRect(size.width*0.8, size.height*0.15,48,48));
this->getView()->addSubview(thirdImage);
CALabel* imageView = CALabel::createWithCenter(CADipRect(size.width*0.25, size.height*0.4, size.width*0.4, _px(50)));
imageView->setText("ImageView");
imageView->setFontSize(_px(30));
imageView->setColor(ccc4(51, 204, 255, 255));
imageView->setTextAlignment(CATextAlignmentCenter);
imageView->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->getView()->addSubview(imageView);
CAImageView* firstImageView = CAImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_normal.png"));
firstImageView->setCenter(CADipRect(size.width*0.25, size.height*0.5, size.width*0.4, size.height*0.1));
//firstImageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
this->getView()->addSubview(firstImageView);
CAImageView* secondImageView = CAImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png"));
secondImageView->setCenter(CADipRect(size.width*0.25, size.height*0.65, size.width*0.4, size.height*0.1));
//secondImageView->setImageViewScaleType(CAImageViewScaleTypeFitImageInside);
this->getView()->addSubview(secondImageView);
CAImageView* thirdImageView = CAImageView::createWithImage(CAImage::create("source_material/slider_indicator.png"));
thirdImageView->setCenter(CADipRect(size.width*0.25, size.height*0.8, size.width*0.4, size.height*0.1));
this->getView()->addSubview(thirdImageView);
CALabel* scale9Image = CALabel::createWithCenter(CADipRect(size.width*0.75, size.height*0.4, size.width*0.4, _px(50)));
scale9Image->setText("Scale9Image");
scale9Image->setFontSize(_px(30));
scale9Image->setColor(ccc4(51, 204, 255, 255));
scale9Image->setTextAlignment(CATextAlignmentCenter);
scale9Image->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->getView()->addSubview(scale9Image);
CAScale9ImageView* firstScale9Image = CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_normal.png"));
firstScale9Image->setCenter(CADipRect(size.width*0.75, size.height*0.5, size.width*0.4, size.height*0.1));
this->getView()->addSubview(firstScale9Image);
CAScale9ImageView* secondScale9Image = CAScale9ImageView::createWithImage(CAImage::create("source_material/btn_rounded3D_selected.png"));
secondScale9Image->setCenter(CADipRect(size.width*0.75, size.height*0.65, size.width*0.4, size.height*0.1));
this->getView()->addSubview(secondScale9Image);
CAScale9ImageView* thirdScale9Image = CAScale9ImageView::createWithImage(CAImage::create("source_material/slider_indicator.png"));
thirdScale9Image->setCenter(CADipRect(size.width*0.75, size.height*0.8, size.width*0.4, size.height*0.1));
this->getView()->addSubview(thirdScale9Image);
//CAImageView* stImageView = CAImageView::createWithImage(CAImage::create("4.jpg"));
//stImageView->setCenter(CADipRect(size.width*0.25, size.height*0.25, size.width*0.4, size.height*0.2));
////stImageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
//this->getView()->addSubview(stImageView);
//CAImageView* pstImageView = CAImageView::createWithImage(CAImage::create("4.jpg"));
//pstImageView->setCenter(CADipRect(size.width*0.25, size.height*0.5, size.width*0.4, size.height*0.2));
//pstImageView->setImageViewScaleType(CAImageViewScaleTypeFitImageCrop);
//this->getView()->addSubview(pstImageView);
//CAImageView* tImageView = CAImageView::createWithImage(CAImage::create("4.jpg"));
//tImageView->setCenter(CADipRect(size.width*0.25, size.height*0.75, size.width*0.4, size.height*0.2));
//tImageView->setImageViewScaleType(CAImageViewScaleTypeFitViewByHorizontal);
//this->getView()->addSubview(tImageView);
}
示例6: showItems
void CATabBar::showItems()
{
do
{
CC_BREAK_IF(m_pViews.empty() == false);
unsigned int count = MIN(m_nMaxShowCount, m_pItems.size());
float width = m_obContentSize.width / count;
float height = m_obContentSize.height;
m_cItemSize = CCSize(width, height);
for (unsigned int i=0; i<count; i++)
{
CAView* view = CAView::createWithFrame(CCRect(i * width, 0, width, height), ccc4(0, 0, 0, 0));
this->insertSubview(view, 3);
view->setDisplayRange(false);
m_pViews.push_back(view);
CAImageView* imageView = NULL;
CCLabelTTF* title = NULL;
if (m_pItems.at(i)->getImage())
{
imageView = CAImageView::createWithImage(m_pItems.at(i)->getImage());
imageView->setTag(0xffff);
view->addSubview(imageView);
}
if (m_pItems.at(i)->getTitle().compare("") != 0)
{
int fontSize = this->getContentSize().height / 5.0f;
title = CCLabelTTF::create(m_pItems.at(i)->getTitle().c_str(), "Arial", fontSize);
title->setTag(0xfffe);
view->addSubview(title);
}
if (imageView && title == NULL)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 2/3.0f;
float scaleY = height / imageViewSize.height * 2/3.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = imageViewSize;
imageView->setCenter(rect);
}
else if (title && imageView == NULL)
{
int fontSize = this->getContentSize().height / 2.0f;
title->setFontSize(fontSize);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 1/2.0f;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect;
rect.origin = view->getBounds().size/2;
rect.size = titleSize;
title->setCenter(rect);
}
else if (title && imageView)
{
CCSize imageViewSize = imageView->getBounds().size;
float scaleX = width / imageViewSize.width * 1/2.0f;
float scaleY = height / imageViewSize.height * 1/2.0f;
float scale = MIN(scaleX, scaleY);
scale = MIN(scale, 1.0f);
imageViewSize = ccpMult(imageViewSize, scale);
CCRect rect;
rect.size = imageViewSize;
rect.origin = view->getBounds().size;
rect.origin.x *= 1/2.0f;
rect.origin.y *= 7/20.0f;
imageView->setCenter(rect);
CCSize titleSize = title->getBounds().size;
float titleScale = height / titleSize.height * 3/10;
titleSize = ccpMult(titleSize, titleScale);
CCRect rect2;
rect2.size = titleSize;
rect2.origin = view->getBounds().size;
rect2.origin.x *= 1/2.0f;
rect2.origin.y *= 15/20.0f;
title->setCenter(rect2);
}
}
//.........这里部分代码省略.........