本文整理汇总了C++中CCRect函数的典型用法代码示例。如果您正苦于以下问题:C++ CCRect函数的具体用法?C++ CCRect怎么用?C++ CCRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CCRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void PatternMatrix::initProgressWithGameMode()
{
mProgressBgSpr = CCSprite::create("ProgressBarBack.png");
mProgressBgSpr->setAnchorPoint(ccp(0, 0.5));
mProgressBgSpr->setPosition(ccp(35, mProgressBgSpr->getContentSize().height + 10));
this->addChild(mProgressBgSpr);
mProgressSpr = CCSprite::create("ProgressBarFront.png");
switch(gGameMode)
{
case Timer:
{
mTimerTally = 0;
mVisibleRect = CCRect(0, 0, 700, 52);
break;
}
case Challenge:
{
mVisibleRect = CCRect(0,0,0,257);
break;
}
}
mProgressSpr->setPosition(ccp(35, mProgressBgSpr->getContentSize().height + 10));
mProgressSpr->setAnchorPoint(ccp(0, 0.5));
mProgressSpr->setTextureRect(mVisibleRect);
this->addChild(mProgressSpr);
}
示例2: CAControl_selector
void SwitchTest::viewDidLoad()
{
size = this->getView()->getBounds().size;
CASwitch* defaultSwitch = CASwitch::createWithCenter(CCRect(size.width*0.5, size.height*0.2, size.width*0.3, 20));
defaultSwitch->setTag(100);
defaultSwitch->addTarget(this,CAControl_selector(SwitchTest::switchStateChange));
this->getView()->addSubview(defaultSwitch);
CASwitch* customSwitch = CASwitch::createWithCenter(CCRect(size.width*0.5, size.height*0.4, size.width*0.3, 20));
customSwitch->setTag(101);
customSwitch->setOnImage(CAImage::create("source_material/btn_rounded_highlighted.png"));
customSwitch->setOffImage(CAImage::create("source_material/btn_rounded_normal.png"));
customSwitch->setThumbTintImage(CAImage::create("source_material/btn_rounded3D_selected.png"));
customSwitch->addTarget(this, CAControl_selector(SwitchTest::switchStateChange));
this->getView()->addSubview(customSwitch);
switchState = CALabel::createWithCenter(CCRect(size.width*0.5, size.height*0.6, size.width*0.5, 50));
switchState->setColor(CAColor_blueStyle);
switchState->setText("Switch State:Off");
switchState->setFontSize(30 * CROSSAPP_ADPTATION_RATIO);
switchState->setTextAlignment(CATextAlignmentCenter);
switchState->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
this->getView()->addSubview(switchState);
}
示例3: ccc4
bool CAScrollView::initWithFrame(const cocos2d::CCRect &rect)
{
if (!CAView::initWithFrame(rect))
{
return false;
}
this->setTouchEnabled(true);
this->setDisplayRange(false);
m_pContainer = CAView::createWithFrame(this->getBounds(), ccc4(255, 255, 255, 0));
m_pChildInThis->addObject(m_pContainer);
this->addSubview(m_pContainer);
m_pIndicatorHorizontal = CAIndicator::createWithFrame(CCRect(12, rect.size.height - 12, rect.size.width - 24, 10), CAIndicator::CAIndicatorTypeHorizontal);
m_pChildInThis->addObject(m_pIndicatorHorizontal);
this->insertSubview(m_pIndicatorHorizontal, 1);
m_pIndicatorVertical = CAIndicator::createWithFrame(CCRect(rect.size.width - 12, 12, 10, rect.size.height - 24), CAIndicator::CAIndicatorTypeVertical);
m_pChildInThis->addObject(m_pIndicatorVertical);
this->insertSubview(m_pIndicatorVertical, 1);
return true;
}
示例4: _px
void CAScrollView::updateIndicator()
{
if (m_pIndicatorHorizontal == NULL)
{
m_pIndicatorHorizontal = CAIndicator::create(CAIndicator::CAIndicatorTypeHorizontal);
m_pChildInThis->addObject(m_pIndicatorHorizontal);
this->insertSubview(m_pIndicatorHorizontal, 1);
}
if (m_pIndicatorVertical == NULL)
{
m_pIndicatorVertical = CAIndicator::create(CAIndicator::CAIndicatorTypeVertical);
m_pChildInThis->addObject(m_pIndicatorVertical);
this->insertSubview(m_pIndicatorVertical, 1);
}
const char indicatorSize = _px(6);
const CCRect indicatorHorizontalFrame = CCRect(indicatorSize * 2,
this->getBounds().size.height - indicatorSize * 2,
this->getBounds().size.width - indicatorSize * 4,
indicatorSize);
m_pIndicatorHorizontal->setFrame(indicatorHorizontalFrame);
const CCRect indicatorVerticalFrame = CCRect(this->getBounds().size.width - indicatorSize * 2,
indicatorSize * 2,
indicatorSize,
this->getBounds().size.height - indicatorSize * 4);
m_pIndicatorVertical->setFrame(indicatorVerticalFrame);
}
示例5: CCRect
void HeroInfoController::loadTopBar(){
CCRect size_top = CCRect(0, 0, _size.width, _size.height / 4);
CAView* _topView = CAView::createWithColor(CAColor_black);
_topView->setFrame(size_top);
this->getView()->addSubview(_topView);
m_pLeftButton = CAButton::createWithFrame(CCRect(_px(10), _px(10), _px(60), _px(60)), CAButtonTypeCustom);
m_pLeftButton->setBackGroundViewForState(CAControlStateNormal, CAImageView::createWithImage(CAImage::create("image/btn_left01")));
m_pLeftButton->setImageForState(CAControlStateNormal, CAImage::create("image/btn_left.png"));
m_pLeftButton->setImageColorForState(CAControlStateHighlighted, CAColor_gray);
m_pLeftButton->addTarget(this, CAControl_selector(HeroInfoController::setButton), CAControlEventTouchUpInSide);
_topView->addSubview(m_pLeftButton);
m_pHeadButton = CAButton::createWithCenter(CCRect(size_top.size.width / 2, size_top.size.height / 2, _px(100), _px(100)), CAButtonTypeCustom);
m_pHeadButton->setImageForState(CAControlStateNormal, CAImage::create(hero->heroIMG));
m_pHeadButton->setImageColorForState(CAControlStateHighlighted, CAColor_red);
_topView->addSubview(m_pHeadButton);
CALabel* m_pHeadLabel = CALabel::createWithCenter(CCRect(size_top.size.width / 2, size_top.size.height / 2 + _px(100), _px(100), _px(100)));
m_pHeadLabel->setTextAlignment(CATextAlignmentCenter);
m_pHeadLabel->setBold(true);
m_pHeadLabel->setFontSize(15);
m_pHeadLabel->setText(UTF8ToGBK::transferToGbk(hero->heroName));
m_pHeadLabel->setColor(CAColor_white);
_topView->addSubview(m_pHeadLabel);
}
示例6: setFrame
void CATextSelectView::showTextSelView(const CCRect& rect, CAView* pControlView, bool showLeft, bool showRight)
{
if (getSuperview() != NULL)
return;
CCSize winSize = CAApplication::getApplication()->getWinSize();
setFrame(CCRect(0, 0, winSize.width, winSize.height));
setColor(CAColor_clear);
setTextTag("CATextSelectView");
CCRect newRect = rect;
if (showLeft)
{
m_pCursorMarkL->setFrame(CCRect(newRect.origin.x - CATextSelectArrWidth, newRect.origin.y + newRect.size.height, CATextSelectArrWidth, CATextSelectArrHeight));
m_pCursorMarkL->setVisible(true);
}
if (showRight)
{
m_pCursorMarkR->setFrame(CCRect(newRect.origin.x + newRect.size.width, newRect.origin.y + newRect.size.height, CATextSelectArrWidth, CATextSelectArrHeight));
m_pCursorMarkR->setVisible(true);
}
m_pTextViewMask->setFrame(newRect);
m_pTextViewMask->setVisible(true);
if (CAView *rootWindow = CAApplication::getApplication()->getRootWindow())
{
rootWindow->removeSubviewByTextTag("CATextSelectView");
rootWindow->addSubview(this);
}
becomeFirstResponder();
m_pControlView = pControlView;
}
示例7: _px
void registerViewController::loadDisButton(CCSize _size, int _lineHeight){
CAButton* button1 = CAButton::createWithFrame(CCRect(-1, 10 + _lineHeight, _size.width / 5, _px(50)), CAButtonTypeCustom);
button1->setAllowsSelected(false);
CAScale9ImageView* imageView = CAScale9ImageView::createWithImage(CAImage::create("image/bg.png"));
button1->setBackGroundViewForState(CAControlStateAll, imageView);
this->getView()->addSubview(button1);
CAView* view1 = CAView::createWithFrame(CCRect(-1, 11 + _lineHeight, _size.width / 5 - 1, _px(48)));
view1->setColor(ccc4(220, 220, 220, 250));
this->getView()->addSubview(view1);
CALabel* label = CALabel::createWithCenter(view1->getCenter());
label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
label->setTextAlignment(CATextAlignmentCenter);
label->setFontSize(_px(20));
if (_lineHeight==0)
{
label->setText("+86");
}
else{
label->setText(UTF8("邀请码"));
}
this->getView()->addSubview(label);
}
示例8: CCRect
void CADrawerController::viewDidLoad()
{
m_rHideFrame[0] = CCRect(-m_fDivision, 0, m_fDivision, this->getView()->getBounds().size.height);
m_rHideFrame[1] = CCRect(0 , 0, this->getView()->getBounds().size.width, this->getView()->getBounds().size.height);
m_rShowFrame[0] = CCRect(0, 0, m_fDivision, this->getView()->getBounds().size.height);
m_rShowFrame[1] = CCRect(m_fDivision , 0, this->getView()->getBounds().size.width, this->getView()->getBounds().size.height);
for (int i=0; i<2; i++)
{
m_pContainer[i] = new CAView();
m_pContainer[i]->setFrame(m_rHideFrame[i]);
this->getView()->addSubview(m_pContainer[i]);
m_pContainer[i]->release();
}
m_pContainer[0]->setAnchorPoint(CCPoint(1.0f, 0.5f));
m_pContainer[1]->setAnchorPoint(CCPoint(0.0f, 0.5f));
m_pLeftViewController->addViewFromSuperview(m_pContainer[0]);
m_pRightViewController->addViewFromSuperview(m_pContainer[1]);
m_bShow = true;
this->hideLeftViewController(false);
if (m_pBackgroundView)
{
m_pBackgroundView->setFrame(this->getView()->getBounds());
}
}
示例9: CATableView
void RootViewController::viewDidLoad()
{
CCRect rect = this->getView()->getBounds();
CCRect tableRect = rect;
tableRect.size.height = rect.size.height - 80;
tableView = new CATableView();
tableView->initWithFrame(tableRect);
tableView->setTableViewDataSource(this);
tableView->setTableViewDelegate(this);
this->getView()->addSubview(tableView);
tableView->release();
CAImageView* v = CAImageView::createWithImage(CAImage::create("2.jpg"));
tableView->setTableHeaderHeight(400);
tableView->setTableHeaderView(v);
CAView* v2 = CAView::createWithFrame(CCRectZero, ccc4(80, 80, 180, 255));
tableView->setTableFooterHeight(200);
tableView->setTableFooterView(v2);
CAView* s = CAView::createWithFrame(CCRectZero, ccc4(127, 127, 127, 127));
tableView->setTablePullDownView(s);
tableView->setTablePullViewHeight(200);
tableView->setBackGroundImage(CAImage::create("bg.jpg"));
CAButton* btn1 = CAButton::createWithFrame(CCRect(10, tableRect.size.height+10, 240, 60));
btn1->setView(CAControlStateNormal, CCLabelTTF::create("unSelected", "Arial", 30));
btn1->setView(CAControlStateSelected, CCLabelTTF::create("selected", "Arial", 30));
btn1->getView(CAControlStateNormal)->setColor(ccBLACK);
btn1->getView(CAControlStateSelected)->setColor(ccBLACK);
this->getView()->addSubview(btn1);
btn1->addTarget(this, CAButton_selector(RootViewController::setAllowsSelection), TouchUpInSide);
btn1->setAllowsSelected(true);
CAButton* btn2 = CAButton::createWithFrame(CCRect(260, tableRect.size.height+10, 240, 60));
btn2->setView(CAControlStateNormal, CCLabelTTF::create("unAllowsMultiple", "Arial", 30));
btn2->setView(CAControlStateSelected, CCLabelTTF::create("allowsMultiple", "Arial", 30));
btn2->getView(CAControlStateNormal)->setColor(ccBLACK);
btn2->getView(CAControlStateSelected)->setColor(ccBLACK);
this->getView()->addSubview(btn2);
btn2->addTarget(this, CAButton_selector(RootViewController::setAllowsMultipleSelection), TouchUpInSide);
btn2->setAllowsSelected(true);
progress = CAProgress::create();
progress->setFrame(CCRect(520, tableRect.size.height+10, 200, 16));
this->getView()->addSubview(progress);
progress->setProgress(0.5f);
CAScheduler::schedule(schedule_selector(RootViewController::updateProgress), this, 5, false);
}
示例10: CCRect
void HoldOnGame::checkCollision(){
//小球与障碍物
CCRect ballRect = playerBall->boundingBox();
CCRect rect = CCRect(ballRect.origin.x + KBallOffset, ballRect.origin.y + KBallOffset,
ballRect.size.width - KBallOffset * 2, ballRect.size.height - KBallOffset * 2);
for (int i = KBodyTypeRectangleVer; i <= KBodyTypeSquare; i++) {
CCSprite* sprite = (CCSprite*)gameLayer->getChildByTag(i);
if (rect.intersectsRect(sprite->boundingBox())) {
bool over = true;
if (sprite->getTag() == KBodyTypeTriangle) {
CCRect sRect = sprite->boundingBox();
CCRect rect1 = CCRect(sRect.origin.x + (sRect.size.width * 0.25) / 2 + KBallOffset, sRect.origin.y,
sRect.size.width * 0.75 - KBallOffset * 2, sRect.size.height * 0.25);
if (!rect.intersectsRect(rect1)) {
rect1 = CCRect(sRect.origin.x + sRect.size.width * 0.25 + KBallOffset, sRect.origin.y + sRect.size.height * 0.25,
sRect.size.width * 0.5 - KBallOffset * 2, sRect.size.height * 0.25);
if (!rect.intersectsRect(rect1)) {
rect1 = CCRect(sRect.origin.x + sRect.size.width * 3 / 8 + KBallOffset, sRect.origin.y + sRect.size.height * 0.5,
sRect.size.width * 0.25 - KBallOffset* 2, sRect.size.height * 0.25);
if (!rect.intersectsRect(rect1)) {
rect1 = CCRect(sRect.origin.x + sRect.size.width * 0.45, sRect.origin.y + sRect.size.height * 0.75,
sRect.size.width * 0.1, sRect.size.height * 0.15);
if (!rect.intersectsRect(rect1)) {
over = false;
} else {
CCLOG("44444 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
}
} else {
CCLOG("333333 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
}
} else {
CCLOG("22222222 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
}
} else {
CCLOG("1111111 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
}
// if (over) {
// CCLOG("rect = (%.1f, %.1f, %.1f, %.1f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
// CCLOG("sRect = (%.1f, %.1f, %.1f, %.1f)", sRect.origin.x, sRect.origin.y, sRect.size.width, sRect.size.height);
// CCLOG("game over");
//// this->gameOver();
// break;
// }
}
if (over) {
this->gameOver();
break;
}
}
}
}
示例11: ccc4
CAView* RootViewController::tableViewSectionViewForFooterInSection(CATableView* table, unsigned int section)
{
CAView* view = CAView::createWithFrame(CCRect(0, 0, 0, 0), ccc4(200, 255, 200, 255));
CCString* str = CCString::createWithFormat("Footer - %u", section);
CCLabelTTF* ttf = CCLabelTTF::create(str->getCString(), "Arial", 20);
ttf->setColor(ccc3(127, 127, 127));
ttf->setFrame(CCRect(10, 10, 0, 0));
view->addSubview(ttf);
return view;
}
示例12: copy
Poker* Poker::copy(){
Poker* pk;
if(m_huaSe != Gui)
pk = Poker::create("poker.png",CCRect(this->m_num*pkWidth,this->m_huaSe*pkHeight,pkWidth,pkHeight));
else
pk = Poker::create("poker.png",CCRect((this->m_num-XiaoGui)*pkWidth,this->m_huaSe*pkHeight,pkWidth,pkHeight));
pk->m_isDianJi = this->m_isDianJi;
pk->m_isSelect = this->m_isSelect;
pk->setHuaSe(this->getHuaSe());
pk->setNum(this->getNum());
pk->m_gameMain = this->m_gameMain;
return pk;
}
示例13: viewDidLoad
void FirstViewController::viewDidLoad()
{
// Do any additional setup after loading the view from its nib.
CAImageView* imageView = CAImageView::createWithImage(CAImage::create("9m.jpg"));
imageView->setFrame(CCRect(200, 300, 330, 214));
this->getView()->addSubview(imageView);
CCLabelTTF* ttf = CCLabelTTF::create("Hello World!", "Arial", 50);
ttf->setColor(ccBLACK);
ttf->setFrame(CCRect(200, 450, 0, 0));
this->getView()->addSubview(ttf);
}
示例14: TMenuItemImage
CCMenuItemImage* TMenuItemImage::create(const char *img, CCObject* target, SEL_MenuHandler selector)
{
CCMenuItemImage *pRet = new TMenuItemImage();
CCTexture2D* ptex = CCTextureCache::sharedTextureCache()->addImage( img );
int tw = ptex->getContentSize().width / 4;
int th = ptex->getContentSize().height;
CCNode* normal = CCSprite::createWithTexture( ptex, CCRect(0, 0, tw, th ) );
CCNode *selected = CCSprite::createWithTexture(ptex, CCRect( tw*2, 0, tw, th) );
CCNode *disabled = CCSprite::createWithTexture( ptex, CCRect( tw*3, 0, tw, th) );
pRet->initWithNormalSprite(normal, selected, disabled, target, selector);
pRet->autorelease();
return pRet;
}
示例15: ccc4
CAView* ThirdViewController::collectionViewSectionViewForHeaderInSection(CACollectionView *collectionView, const CCSize& viewSize, unsigned int section)
{
CAView* view = CAView::createWithFrame(CCRect(0, 0, 0, 0), ccc4(224, 224, 224, 255));
CCString* str = CCString::createWithFormat("Section Header - %u", section);
CALabel* label = CALabel::createWithFrame(CCRect(20, 0, 200, viewSize.height));
label->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
label->setFontSize(24);
label->setText(str->getCString());
label->setColor(ccc4(127, 127, 127, 255));
view->addSubview(label);
return view;
}