本文整理汇总了C++中TextureCache::removeTextureForKey方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureCache::removeTextureForKey方法的具体用法?C++ TextureCache::removeTextureForKey怎么用?C++ TextureCache::removeTextureForKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureCache
的用法示例。
在下文中一共展示了TextureCache::removeTextureForKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*!
@brief デストラクタ
画像とテクスチャを解放する。
*/
AKGauge::~AKGauge()
{
// 画像を解放する
m_emptyImage->removeFromParentAndCleanup(true);
m_fullImage->removeFromParentAndCleanup(true);
// テクスチャを解放する
TextureCache *cache = Director::getInstance()->getTextureCache();
cache->removeTextureForKey(m_emptyFileName);
cache->removeTextureForKey(m_fullFileName);
}
示例2: createStatsLabel
void Director::createStatsLabel()
{
Texture2D *texture = NULL;
TextureCache *textureCache = TextureCache::getInstance();
if( _FPSLabel && _SPFLabel )
{
CC_SAFE_RELEASE_NULL(_FPSLabel);
CC_SAFE_RELEASE_NULL(_SPFLabel);
CC_SAFE_RELEASE_NULL(_drawsLabel);
textureCache->removeTextureForKey("cc_fps_images");
FileUtils::getInstance()->purgeCachedEntries();
}
Texture2DPixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
unsigned char *data = NULL;
unsigned int data_len = 0;
getFPSImageData(&data, &data_len);
Image* image = new Image();
bool isOK = image->initWithImageData(data, data_len);
if (!isOK) {
CCLOGERROR("%s", "Fails: init fps_images");
return;
}
texture = textureCache->addUIImage(image, "cc_fps_images");
CC_SAFE_RELEASE(image);
/*
We want to use an image which is stored in the file named ccFPSImage.c
for any design resolutions and all resource resolutions.
To achieve this,
Firstly, we need to ignore 'contentScaleFactor' in 'AtlasNode' and 'LabelAtlas'.
So I added a new method called 'setIgnoreContentScaleFactor' for 'AtlasNode',
this is not exposed to game developers, it's only used for displaying FPS now.
Secondly, the size of this image is 480*320, to display the FPS label with correct size,
a factor of design resolution ratio of 480x320 is also needed.
*/
float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f;
_FPSLabel = new LabelAtlas();
_FPSLabel->setIgnoreContentScaleFactor(true);
_FPSLabel->initWithString("00.0", texture, 12, 32 , '.');
_FPSLabel->setScale(factor);
_SPFLabel = new LabelAtlas();
_SPFLabel->setIgnoreContentScaleFactor(true);
_SPFLabel->initWithString("0.000", texture, 12, 32, '.');
_SPFLabel->setScale(factor);
_drawsLabel = new LabelAtlas();
_drawsLabel->setIgnoreContentScaleFactor(true);
_drawsLabel->initWithString("000", texture, 12, 32, '.');
_drawsLabel->setScale(factor);
Texture2D::setDefaultAlphaPixelFormat(currentFormat);
_drawsLabel->setPosition(Point(0, 34*factor) + CC_DIRECTOR_STATS_POSITION);
_SPFLabel->setPosition(Point(0, 17*factor) + CC_DIRECTOR_STATS_POSITION);
_FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
}