本文整理汇总了C++中CCScale9Sprite::resizableSpriteWithCapInsets方法的典型用法代码示例。如果您正苦于以下问题:C++ CCScale9Sprite::resizableSpriteWithCapInsets方法的具体用法?C++ CCScale9Sprite::resizableSpriteWithCapInsets怎么用?C++ CCScale9Sprite::resizableSpriteWithCapInsets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCScale9Sprite
的用法示例。
在下文中一共展示了CCScale9Sprite::resizableSpriteWithCapInsets方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}