本文整理汇总了C++中CCRectMake函数的典型用法代码示例。如果您正苦于以下问题:C++ CCRectMake函数的具体用法?C++ CCRectMake怎么用?C++ CCRectMake使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CCRectMake函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCRectMake
//------------------------------------------------------------------
//
// TextureGlRepeat
//
//------------------------------------------------------------------
void TextureGlRepeat::onEnter()
{
TextureDemo::onEnter();
CCSize size = CCDirector::sharedDirector()->getWinSize();
// The .png image MUST be power of 2 in order to create a continue effect.
// eg: 32x64, 512x128, 256x1024, 64x64, etc..
CCSprite *sprite = CCSprite::spriteWithFile("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096));
addChild(sprite, -1, kTagSprite1);
sprite->setPosition(ccp(size.width/2,size.height/2));
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
sprite->getTexture()->setTexParameters(¶ms);
CCRotateBy* rotate = CCRotateBy::actionWithDuration(4, 360);
sprite->runAction(rotate);
CCScaleBy* scale = CCScaleBy::actionWithDuration(2, 0.04f);
CCScaleBy* scaleBack = (CCScaleBy*) (scale->reverse());
CCFiniteTimeAction* seq = CCSequence::actions(scale, scaleBack, NULL);
sprite->runAction(seq);
}
示例2: CCArray
CCArray* AnimationComponent::eightDirectionActionListWithFile(const char* file ,int frameCount ,CCSize frameSize ,float delay)
{
CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage(file);
CCArray* actions=new CCArray();
actions->initWithCapacity(8);
//move action
for (int i=0; i<8; i++) {
CCArray* animFrames=new CCArray();
animFrames->initWithCapacity(frameCount);
for (int j=0; j<frameCount; j++) {
CCSpriteFrame *frame=CCSpriteFrame::createWithTexture(texture ,CCRectMake(j*frameSize.width, i*frameSize.height, frameSize.width, frameSize.height));
animFrames->addObject(frame);
}
CCAnimation *animation=CCAnimation::createWithSpriteFrames(animFrames,delay);
CCAnimate *animate= CCAnimate::create(animation);
actions->addObject(CCRepeatForever::create((CCActionInterval*)CCSequence::create(animate,NULL)));
animFrames->release();
}
return actions;
}
示例3: CC_BREAK_IF
bool CTank::init(CCNode *parent, char szTankPlist[], char szTankPng[])
{
bool bRet = true;
do
{
CCSpriteFrameCache* cache = CGameManager::getGameManager()->getFrameCache();
CC_BREAK_IF(!cache);
cache->addSpriteFramesWithFile(szTankPlist, szTankPng);
CCSize tileSize = CGameScene::getTileSize();
CCSprite *tank = CCSprite::spriteWithFile("material/tank2/tank_up.png",
CCRectMake(0,0,tileSize.width*2, tileSize.height*2));
//tank->setScale(DEFAULT_TANK_SCALE);
CC_BREAK_IF(!tank);
m_pTank = tank;
tank->setScale(2);
tank->setPosition(ccp(tileSize.width,tileSize.height));
this->addChild(tank);
parent->addChild(this);
m_TankDirection = MOVE_UP;
changeTankImage(MOVE_UP);
setActive(true);
bRet = true;
}while(0);
return bRet;
}
示例4: addChild
bool GameScene::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
if(NULL==map){
map=TMXTiledMap::create("map/map1.tmx");
}
//map->setScale(2);
addChild(map);
TMXObjectGroup *objects = map->getObjectGroup("player");
CCASSERT(NULL != objects, "'Objects' object group not found");
auto spawnPoint = objects->getObject("playerinit");
CCASSERT(!spawnPoint.empty(), "SpawnPoint object not found");
int x = spawnPoint["x"].asInt();
int y = spawnPoint["y"].asInt();
Player * player = new Player();
global->player=player;
global->map=map;
player->setPosition(Vec2(x,y));
addChild(player,2);
//player->sprite->runAction(RepeatForever::create(Animate::create(global->createAni(player->texture, 3))));
TMXObjectGroup *object2=map->getObjectGroup("Event");
auto transitionpoint=object2->getObject("transitionEvent");
int x1=transitionpoint["x"].asInt();
int y1=transitionpoint["y"].asInt();
transitionPosition=Vec2(x1,y1);
//CCLOG("over");
this->runAction(CCFollow::create(player,CCRectMake(0,0,map->getContentSize().width,map->getContentSize().height)));
schedule(schedule_selector(GameScene::updateEvent), 0.1);
return true;
}
示例5: switch
void UISlider::setPercent(int percent)
{
if (percent > 100)
{
percent = 100;
}
if (percent < 0)
{
percent = 0;
}
m_nPercent = percent;
float dis = m_fBarLength*(percent/100.0f);
m_pSlidBallRenderer->setPosition(ccp(-m_fBarLength/2.0f + dis, 0.0f));
if (m_bScale9Enabled)
{
dynamic_cast<CCScale9Sprite*>(m_pProgressBarRenderer)->setPreferredSize(CCSizeMake(dis,m_ProgressBarTextureSize.height));
}
else
{
int x = 0, y = 0;
switch (m_eProgressBarTexType)
{
case UI_TEX_TYPE_PLIST:
{
CCSprite* barNode = dynamic_cast<CCSprite*>(m_pProgressBarRenderer);
if (barNode)
{
CCPoint to = barNode->getTextureRect().origin;
x = to.x;
y = to.y;
}
break;
}
default:
break;
}
dynamic_cast<CCSprite*>(m_pProgressBarRenderer)->setTextureRect(CCRectMake(x, y, m_ProgressBarTextureSize.width * (percent/100.0f), m_ProgressBarTextureSize.height));
}
}
示例6: setBackGroundImage
void OptionLayer::setViews()
{
setBackGroundImage("loading.png");
CCSprite *title = CCSprite::create("menuTitle.png",CCRectMake(0,0,135,35));
title->setAnchorPoint(ccp(0.5,1));
title->setPosition(ccp(getWinSize().width/2,getWinSize().height-20));
this->addChild(title);
CCMenuItemToggle *music_trigger = CCMenuItemToggle::createWithTarget(this,menu_selector(OptionLayer::music_triggerCallback),
CCMenuItemFont::create("Music : On"),CCMenuItemFont::create("Music : Off"),NULL);
music_trigger->setPosition(ccp(getWinSize().width/2,getWinSize().height/2));
if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
{
music_trigger->setSelectedIndex(1);
}
else
{
music_trigger->setSelectedIndex(0);
}
//menu->setPosition(ccp(getWinSize().width/2,getWinSize().height/2));
CCLabelBMFont *back = CCLabelBMFont::create("back","arial-14.fnt");
back->setScale(1.25f);
CCMenuItemLabel *backLable = CCMenuItemLabel::create(back,this,menu_selector(OptionLayer::backCallback));
backLable->setAnchorPoint(ccp(0.5,1));
backLable->setPosition(ccp(getWinSize().width/2,50));
CCMenu *menu = CCMenu::create(music_trigger,backLable,NULL);
menu->setPosition(CCPointZero);
this->addChild(menu);
}
示例7: addChild
bool About::init()
{
if (!CCLayer::init()) {
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite *sp = CCSprite::create(s_bg01);
sp->setPosition(ccp(winSize.width / 2, winSize.height / 2));
addChild(sp, 0, 1);
CCTexture2D *imageCache = CCTextureCache::sharedTextureCache()->addImage(s_menuTitle);
CCSprite *title = CCSprite::createWithTexture(imageCache, CCRectMake(0, 36, 100, 34));
title->setPosition(ccp(winSize.width/2, winSize.height - 60));
addChild(title);
CCLabelTTF *about = CCLabelTTF::create(" Thanks to cocos2d!", "Arial Bold", 32, CCSizeMake(winSize.width * 0.85, 320), kCCTextAlignmentLeft);
about->setPosition(ccp(winSize.width / 2, winSize.height / 2 ));
addChild(about);
CCLabelBMFont *backLb = CCLabelBMFont::create("Go Back", s_font);
CCMenuItemLabel *goBack = CCMenuItemLabel::create(backLb, this, menu_selector(About::goBack));
goBack->setScale(0.6f);
CCActionInterval *fadeIn = CCFadeTo::create(1, 80);
CCActionInterval *fadeOut = CCFadeTo::create(1, 255);
CCEaseSineInOut *ease1 = CCEaseSineInOut::create(fadeIn);
CCEaseSineInOut *ease2 = CCEaseSineInOut::create(fadeOut);
CCFiniteTimeAction *seq = CCSequence::create(ease1, ease2, NULL);
// 参数必须要强转,不然ndk编译不过
goBack->runAction(CCRepeatForever::create((CCActionInterval*)seq));
CCMenu *menu = CCMenu::create(goBack, NULL);
menu->setPosition(winSize.width / 2, winSize.height/2 - 60);
addChild(menu);
return true;
}
示例8: NDUILayer
//===========================================================================
bool CSMLoginScene::CreatConfirmDlg( const char * szTip )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSizeInPixels();
NDUILayer * pLayer = new NDUILayer();
if ( !pLayer )
return false;
pLayer->Initialization();
pLayer->SetFrameRect( CCRectMake(0, 0, winSize.width, winSize.height) );
pLayer->SetTag( TAG_DLG_CONFIRM );
AddChild(pLayer);
NDUILoad tmpUILoad2;
tmpUILoad2.Load( "ShowYesOrNoDlg.ini", pLayer, this, CCSizeMake(0, 0) );
NDUILabel * pLabelTip = (NDUILabel*)pLayer->GetChild( TAG_LABEL_TIP );
if ( pLabelTip && szTip )
{
pLabelTip->SetText( szTip );
}
return true;
}
示例9: convertToNodeSpace
bool TitleBar::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
CCPoint touchLocation = touch->locationInView( touch->view() );
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
CCPoint pos = convertToNodeSpace( touchLocation );
CCSize sz = getContentSizeInPixels();
bool bRet = CCRect::CCRectContainsPoint(CCRectMake(0,
0,
sz.width,
sz.height),
pos);
if (bRet) {
CCNotificationCenter::sharedNotifCenter()->postNotification(kNotifyGoTop);
return true;
}
else{
return false;
}
}
示例10: switch
void UILoadingBar::setPercent(int percent)
{
if ( percent < 0 || percent > 100)
{
return;
}
if (m_fTotalLength <= 0)
{
return;
}
m_nPercent = percent;
float res = m_nPercent/100.0;
int x = 0, y = 0;
switch (m_eRenderBarTexType)
{
case UI_TEX_TYPE_PLIST:
{
CCSprite* barNode = DYNAMIC_CAST_CCSPRITE;
if (barNode)
{
CCPoint to = barNode->getTextureRect().origin;
x = to.x;
y = to.y;
}
break;
}
default:
break;
}
if (m_bScale9Enabled)
{
setScale9Scale();
}
else
{
dynamic_cast<CCSprite*>(m_pBarRenderer)->setTextureRect(CCRectMake(x, y, m_barRendererTextureSize.width * res, m_barRendererTextureSize.height));
}
}
示例11: ccp
/**
* 检查是否在区域里
*/
bool UILineValue::touchDown(float x,float y)
{
CCPoint pos = ccp(x,y);
pos = this->convertToNodeSpace(pos);
nowTouchPoint = ccp(x,y);
if (_back)
{
float width = _back->getContentSize().width * _back->getScaleX();
float height = _back->getContentSize().height * _back->getScaleY();
CCRect rect = CCRectMake(
_back->getPosition().x ,
_back->getPosition().y,
width,
height);
if (rect.containsPoint(pos))
{
_touchIn = true;
return true;
}
}
return false;
}
示例12: initView
void SGEquipBox::initView()
{
ResourceManager::sharedInstance()->bindTexture("sgequipslayer/sgequipslayer.plist", RES_TYPE_LAYER_UI, sg_box_equipBox);
CCSize s = CCDirector::sharedDirector()->getWinSize();
tableViewHeight = 70;
tableView->setFrame(CCRectMake(0, 0, 380, 300));
tableView->setPosition(ccpAdd(SGLayout::getPoint(kMiddleLeft), ccp(s.width/2-tableView->getContentSize().width/2,-180)));
SGButton *ok = SGButton::create("box_btnbg.png",
"public_font_queding.png",
this,
menu_selector(SGEquipBox::boxCloseWithOutCallBack),
ccp(0, 0),
false,
true);
this->addBtn(ok);
ok->setPosition(ccpAdd(SGLayout::getPoint(kMiddleCenter), ccp(0, -260)));
CCSprite *title = CCSprite::createWithSpriteFrameName("font_taozsx.png");
title->setPosition(ccpAdd(SGLayout::getPoint(kMiddleCenter), ccp(0, 150)));
this->addChild(title);
}
示例13: CCLOG
void Box2DTestLayer::addNewSpriteAtPosition(CCPoint p)
{
CCLOG("Add sprite %0.2f x %02.f",p.x,p.y);
CCNode* parent = getChildByTag(kTagParentNode);
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
//just randomly picking one of the images
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
PhysicsSprite *sprite = new PhysicsSprite();
sprite->initWithTexture(m_pSpriteTexture, CCRectMake(32 * idx,32 * idy,32,32));
sprite->autorelease();
parent->addChild(sprite);
sprite->setPosition( ccp( p.x, p.y) );
// Define the dynamic body.
//Set up a 1m squared box in the physics world
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
b2Body *body = world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.3f;
body->CreateFixture(&fixtureDef);
sprite->setPhysicsBody(body);
}
示例14: sprintf
ToyBrick* ToyLayer::CreateBrick_Rectangle()
{
int num = CommonHelper::GetRandomNum(1, 20);
//image && texture
char path[255];
sprintf(path, "Images/ToyBrick/Rectangle/%d.png", num);
CCImage *img = new CCImage();
img->autorelease();
if (!img->initWithImageFile(path, cocos2d::CCImage::kFmtPng))
{
return NULL;
}
CCTexture2D *texture = new CCTexture2D();
texture->autorelease();
if (!texture->initWithImage(img))
{
return NULL;
}
//
ToyBrick *brick = ToyBrick::create();
CCSize size = texture->getContentSize();
brick->Init(texture, CCRectMake(0, 0, size.width, size.height));
//vector
CCPointArray *vector = CCPointArray::create(4);
vector->addControlPoint(ccp(-52, -52));
vector->addControlPoint(ccp(52, -52));
vector->addControlPoint(ccp(52, 52));
vector->addControlPoint(ccp(-52, 52));
brick->SetAsPolygon(vector);
return brick;
}
示例15: CCRectMake
void CocoRoomTodayCandy::InitSprites()
{
pBlack = CCSprite::create("images/ranking_scrollbg.png", CCRectMake(0, 0, winSize.width, winSize.height));
pBlack->setPosition(ccp(0, 0));
pBlack->setAnchorPoint(ccp(0, 0));
pBlack->setColor(ccc3(0, 0, 0));
pBlack->setOpacity(150);
this->addChild(pBlack, 0);
spriteClass = new SpriteClass();
// make pop-up background
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_brown.png1",
ccp(0, 0), ccp(49, 458), CCSize(982, 1073), "", "Layer", tLayer, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_yellow.png1",
ccp(0, 0), ccp(75, 492), CCSize(929, 904), "", "Layer", tLayer, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "letter/letter_todaystarcandy_groupfriend_select.png", ccp(0, 0), ccp(103, 1429), CCSize(0, 0), "", "Layer", tLayer, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "button/btn_x_brown.png",
ccp(0, 0), ccp(900, 1420), CCSize(0, 0), "", "Layer", tLayer, 1) );
// bottom background
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_brown.png2",
ccp(0, 0), ccp(49, 198), CCSize(982, 223), "", "Layer", tLayer, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_yellow.png2",
ccp(0, 0), ccp(77, 228), CCSize(929, 177), "", "Layer", tLayer, 1) );
// bottom 5 profile 중에 내 프로필
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, MyInfo::GetProfile(), ccp(0, 0), ccp(100+5, 254+11), CCSize(0,0), "", "Layer", tLayer, 5, 0, 255, 0.95f) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "background/bg_profile.png1", ccp(0, 0), ccp(100, 254), CCSize(0, 0), "", "Layer", tLayer, 5) );
// bottom button
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "button/btn_red_mini.png",
ccp(0, 0), ccp(750, 262), CCSize(0, 0), "", "Layer", tLayer, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "letter/letter_confirm_mini.png",
ccp(0.5, 0), ccp(spriteClass->spriteObj[spriteClass->spriteObj.size()-1]->sprite->getContentSize().width/2, 27), CCSize(0, 0), "button/btn_red_mini.png", "0", NULL, 1, 1) );
}