本文整理汇总了C++中CCScale9Sprite::setScaleX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::setScaleX方法的具体用法?C++ CCScale9Sprite::setScaleX怎么用?C++ CCScale9Sprite::setScaleX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCScale9Sprite
的用法示例。
在下文中一共展示了CCScale9Sprite::setScaleX方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetBgAni
void CCtrlPage::SetBgAni(const char* pszAni)
{
if (NULL == pszAni)
{
return;
}
clearBackgroundSprite();
m_strAniSection = std::string(pszAni);
if (m_strAniSection.empty())
{
return;
}
CMyIniPtr pAni = g_objIniMgr.GetMyIniPtr(m_strAniPath.c_str());
if (!pAni)
{
return;
}
int nFrame = 0;
std::string strFrame = FORMAT("Frame%d")<<nFrame;
const char *pszValue = pAni->GetString(m_strAniSection.c_str(), strFrame.c_str());
if (NULL == pszValue)
{
return;
}
CCScale9Sprite *backgroundSprite = CCScale9Sprite::create(pszValue);
if (!backgroundSprite)
{
return;
};
// 不为9宫格方式
if (enumUISTRETCH_NORMAL == m_nAniStretch)
{
CCRect rectCapInsets = CCRectMake(0, 0, backgroundSprite->getContentSize().width, backgroundSprite->getContentSize().height);
backgroundSprite->removeAllChildren();
CCScale9Sprite *backgroundSpriteResize = backgroundSprite->resizableSpriteWithCapInsets(rectCapInsets);
CHECK(backgroundSpriteResize);
setBackgroundSprite(backgroundSpriteResize);
}
else if (enumUISTRETCH_STRETCH == m_nAniStretch)
{
float fOrgWidth = backgroundSprite->getContentSize().width;
float fOrgHeight = backgroundSprite->getContentSize().height;
CCRect rectCapInsets = CCRectMake(0, 0, fOrgWidth, fOrgHeight);
backgroundSprite->removeAllChildren();
CCScale9Sprite *backgroundSpriteResize = backgroundSprite->resizableSpriteWithCapInsets(rectCapInsets);
CHECK(backgroundSpriteResize);
float fScaleX = 1.0f;
float fScaleY = 1.0f;
if (0.0f != fOrgWidth && 0.0f != fOrgHeight)
{
fScaleX = (float)m_nWidth / fOrgWidth;
fScaleY = (float)m_nHeight / fOrgHeight;
}
backgroundSpriteResize->setScaleX(fScaleX);
backgroundSpriteResize->setScaleY(fScaleY);
setBackgroundSprite(backgroundSpriteResize);
}
else
{
setBackgroundSprite(backgroundSprite);
}
CHECK(m_backgroundSprite);
m_backgroundSprite->setAnchorPoint(ccp(0, 0));
m_backgroundSprite->setPosition(ccp(0, 0));
this->addChild(m_backgroundSprite, 0);
}
示例2: init
bool CCLobbyView::init( CCNetworkLogic* network, const CCSize& mySize )
{
if( CCLayer::init() )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
CCPoint position = CCPointZero;
CCSize size = CCSizeZero;
int length = 0;
int fontSize = 0;
this->setNetwork( network );
CCSprite* s = CCSprite::create("Images/r1.png");
s->retain();
CCRect rect = CCRectZero;
rect.size = s->getContentSize();
s->release();
fontSize = 12;
CCLabelTTF* label = CCLabelTTF::create( "Connect", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
CCScale9Sprite* sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
CCControlButton* button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::connectButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x -= 100;
button->setPosition( position );
this->setConnectButton( button );
label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.4f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
//position.x += 0;
button->setPosition( position );
this->setCreateGameButton( button );
label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
label->setColor( ccc3( 0, 0, 0 ) );
sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
sprite->setScaleX( 1.6f );
sprite->setScaleY( 0.8f );
button = CCControlButton::create( label, sprite );
button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
button->setPreferredSize( rect.size );
position = center;
position.y -= 136;
position.x += 100;
button->setPosition( position );
this->setRandomGameButton( button );
this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );
fontSize = 16;
length = mySize.width;
size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
size.height *= 3;
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
position = center;
position.x -= size.width * 0.5f;
position.y -= fontSize + ( size.height * 0.17f );
table->setPosition( position );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
this->setRoomTable( table );
table->reloadData();
fontSize = 16;
label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
position = center;
position.x -= size.width * 0.4f;
position.y += size.height - ( fontSize * 0.5f );
label->setPosition( position );
//label->setAnchorPoint( CCPointZero );
this->setRoomTableLabel( label );
fontSize = 16;
CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
console->setColor( ccc3(255, 255, 255) );
console->setContentSize(winSize);
position = center;
position.y += 100;
console->setPosition( position );
//.........这里部分代码省略.........