本文整理汇总了C++中CCRect::setRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRect::setRect方法的具体用法?C++ CCRect::setRect怎么用?C++ CCRect::setRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRect
的用法示例。
在下文中一共展示了CCRect::setRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsPutable
bool CBoxBehaviorState::IsPutable(CCSprite* sprite, CCPoint touchPos, CCPoint& avaliablePos)
{
auto arr = CObjectManager::getInstance()->getBox2dSprite();
CCPoint setPos;
bool bIsEnable = true;
CCRect rect;
for (int i = 0; i <= 20; i++)
{
for (int j = 0; j <= 20; j++)
{
CCRect r;
r.setRect(i * 105 + CScrollManager::getInstance()->getDeltaPosition().x, j * 105 + CScrollManager::getInstance()->getDeltaPosition().y, 105, 105);
if (r.containsPoint(touchPos))
{
setPos = ccp(r.getMidX(), r.getMidY());
rect = r;
}
}
}
for (int i = 0; i < arr->getSize(); i++)
{
auto anothersprite = arr->getObjectAt(i)->getSpritePtr();
if (rect.intersectsRect(anothersprite->getBoundingBox()))
bIsEnable = false;
}
avaliablePos = setPos;
return bIsEnable;
}
示例2: collisionBoundingBox
CCRect Player::collisionBoundingBox() {
CCRect collisionBox = this->boundingBox();
CCPoint diff = ccpSub(this->desiredPosition, this->getPosition());
CCRect returnBoundingBox;
returnBoundingBox.setRect(collisionBox.getMinX() + diff.x, collisionBox.getMinY() + diff.y, collisionBox.getMaxX()-collisionBox.getMinX(), collisionBox.getMaxY()-collisionBox.getMinY());
return returnBoundingBox;
// return CCRect::intersectsRect(this->boundingBox, 2, 0);
}
示例3: showHp
void CGameMessage::showHp()
{
int iHp = CGameManager::getPlayer()->getHp();
int iHpMax = CGameManager::getPlayer()->getHpMax();
CCRect rect;
rect.setRect(m_fMinX, m_fMinY, m_iWidth*(float)iHp/iHpMax, m_iHeight);
m_pHp->setTextureRect(rect);
}
示例4: copyWithZone
CCObject* CCRect::copyWithZone(CCZone* pZone)
{
CCRect* pRet = new CCRect();
pRet->setRect(this->origin.x, this->origin.y, this->size.width, this->size.height);
return pRet;
}
示例5: setScore
void GameShare_Score::setScore(long var)
{
score = var;
mpCounterImage->setNumber(score,true);
long temp = score;
//位数,用于设置横坐标偏移量.
int digit = 0;
scroeSprite->removeAllChildren();
while (temp>0 || (digit==0 && temp==0)) {
int remainder = temp % 10;
temp = temp/10;
CCSprite *m_Sprite = CCSprite::create();
CCRect rc;
switch(remainder)
{
case 0:
{
rc.setRect(1694, 972, 70, 70);
break;
}
case 1:
{
rc.setRect(1, 1279, 47, 85);
break;
}
case 2:
{
rc.setRect(337, 1054, 68, 86);
break;
}
case 3:
{
rc.setRect(1687, 1417, 69, 84);
break;
}
case 4:
{
rc.setRect(401, 1691, 71, 83);
break;
}
case 5:
{
rc.setRect(1699, 105, 70, 85);
break;
}
case 6:
{
rc.setRect(981, 1714, 69, 91);
break;
}
case 7:
{
rc.setRect(359, 897, 64, 85);
break;
}
case 8:
{
rc.setRect(348, 1517, 72, 88);
break;
}
case 9:
{
rc.setRect(191, 1699, 65, 91);
break;
}
default:
{
break;
}
}
m_Sprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoopang_image, rc);
m_Sprite->setScaleX(xValue / rc.size.width);
m_Sprite->setScaleY(yValue / rc.size.height);
m_Sprite->setPosition(ccp((digit+(digit/3))*(-20), 0));
scroeSprite->addChild(m_Sprite);
if (digit%3==0 && digit>0) {
CCSprite *comma = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoopang_image, CCRect(252, 1076, 32, 36));
comma->setScale(0.5);
comma->setPosition(ccp(m_Sprite->getPositionX()+20, -20));
scroeSprite->addChild(comma);
}
digit++;
}
scroeSprite->setPosition(ccp(digit*12 - 17, -25));
}
示例6: init
bool StageSelect::init(){
if ( !CCLayerColor::initWithColor( ccc4( 0xff, 0xff, 0xff, 0xff ) ) ){
return false;
}
scheduleUpdate();
//クリアステージの読み込み
mUserDefault = CCUserDefault::sharedUserDefault();
CCSprite* spriteBack = CCSprite::create( "image/stageBack.png" );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
spriteBack->setPosition( ccp( winSize.width / 2, winSize.height / 2 ) );
addChild( spriteBack );
mNumStage = 21;
mButtons = new CCMenu*[ mNumStage ];
mNumLeftSprites = new CCSprite*[ mNumStage ];
mNumRightSprites = new CCSprite*[ mNumStage ];
mCheckSprite = new CCSprite*[ mNumStage ];
CCTexture2D* numberTex = CCTextureCache::sharedTextureCache()->addImage( "image/number.png" );
for ( int i = 0; i < mNumStage; i++ ){
CCMenuItemImage* item = CCMenuItemImage::create( "image/stagebutton_0.png", "image/stagebutton_1.png", this, menu_selector( StageSelect::stageSelectCallback ) );
item->setTag( i );
mButtons[ i ] = CCMenu::create( item, NULL );
float x = mButtonListLeft + i * mButtonIntervalX;
float y = mButtonListUp + ( i % 2 ) * mButtonIntervalY;
ScreenConverter::toLeftUp( &y );
mButtons[ i ]->setPosition( ccp( x, y ) );
addChild( mButtons[ i ] );
//クリアチェック
mCheckSprite[ i ] = CCSprite::create( "image/clear_check.png" );
mCheckSprite[ i ]->setPosition( ccp(x,y) );
addChild(mCheckSprite[ i ]);
CCString* keyStr = CCString::createWithFormat( "stageCleared%d", i ) ;
if(!mUserDefault->getBoolForKey(keyStr->getCString(),false)){
mCheckSprite[ i ]->setVisible( false );
}
int n = i + 1;
CCRect rect;
rect.setRect( ( n % 10 ) * 32, 0, 32, 32 );
mNumRightSprites[ i ] = CCSprite::createWithTexture( numberTex, rect );
rect.setRect( ( n / 10 ) * 32, 0, 32, 32 );
mNumLeftSprites[ i ] = CCSprite::createWithTexture( numberTex, rect );
mNumRightSprites[ i ]->setPosition( ccp( x + 16, y ) );
mNumLeftSprites[ i ]->setPosition( ccp( x - 16, y ) );
addChild( mNumRightSprites[ i ] );
addChild( mNumLeftSprites[ i ] );
}
mPlayerA = CCSprite::create( "image/ship_stage.png" );
mPlayerB = CCSprite::create( "image/ship_stage.png" );
mPlayerA->setPosition( ccp( -100.0f, 90.0f ) );
mPlayerA->setRotation( 90 );
mPlayerB->setPosition( ccp( winSize.width + 100.0f, winSize.height - 90.0f ) );
mPlayerB->setRotation( -90 );
addChild( mPlayerA, 1 );
addChild( mPlayerB, 1 );
for ( int i = 0; i < 5; i++ ){
mRipplesA[ i ] = new Ripple( -30 * i - 1, true );
mRipplesA[ i ]->setParent( this, 0 );
mRipplesB[ i ] = new Ripple( -30 * i - 1, true );
mRipplesB[ i ]->setParent( this, 0 );
}
setTouchMode( kCCTouchesOneByOne );
setTouchEnabled( true );
mIsTouch = false;
mOnSequence = false;
mTimeCount = 0;
return true;
}