mirror of https://github.com/axmolengine/axmol.git
add a member function to get key string of a texture.
This commit is contained in:
parent
5589335d3a
commit
e53649ccaa
|
@ -107,6 +107,8 @@ public:
|
||||||
*/
|
*/
|
||||||
CCTexture2D* addUIImage(CCImage *image, const char *key);
|
CCTexture2D* addUIImage(CCImage *image, const char *key);
|
||||||
|
|
||||||
|
const char* getKeyForTexture(CCTexture2D* texture);
|
||||||
|
|
||||||
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
/** Returns an already created texture. Returns nil if the texture doesn't exist.
|
||||||
@since v0.99.5
|
@since v0.99.5
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,6 +36,7 @@ THE SOFTWARE.
|
||||||
#include "CCFileUtils.h"
|
#include "CCFileUtils.h"
|
||||||
#include "CCImage.h"
|
#include "CCImage.h"
|
||||||
#include "support/ccUtils.h"
|
#include "support/ccUtils.h"
|
||||||
|
#include "CCString.h"
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
|
@ -398,6 +399,23 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key)
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* CCTextureCache::getKeyForTexture(CCTexture2D* texture)
|
||||||
|
{
|
||||||
|
if( ! texture )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
std::vector<std::string> keys = m_pTextures->allKeysForObject(texture);
|
||||||
|
|
||||||
|
if (keys.size() == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
CCString *pRet = new CCString();
|
||||||
|
pRet->autorelease();
|
||||||
|
pRet->m_sString = keys[0];
|
||||||
|
|
||||||
|
return pRet->m_sString.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
// TextureCache - Remove
|
// TextureCache - Remove
|
||||||
|
|
||||||
void CCTextureCache::removeAllTextures()
|
void CCTextureCache::removeAllTextures()
|
||||||
|
|
Loading…
Reference in New Issue