[cocos2dx] allow load custom atlas texture in _spAtlasPage_createTexture for CocosCreator (#1018)

This commit is contained in:
Jare Guo 2017-10-13 02:50:03 -05:00 committed by Mario Zechner
parent 77221b4cee
commit 041b6ddb00
2 changed files with 20 additions and 1 deletions

View File

@ -31,6 +31,13 @@
#include <spine/spine-cocos2dx.h>
#include <spine/extension.h>
namespace spine {
static CustomTextureLoader _customTextureLoader = nullptr;
void spAtlasPage_setCustomTextureLoader (CustomTextureLoader texLoader) {
_customTextureLoader = texLoader;
}
}
USING_NS_CC;
GLuint wrap (spAtlasWrap wrap) {
@ -60,7 +67,13 @@ GLuint filter (spAtlasFilter filter) {
}
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
Texture2D* texture = nullptr;
if (spine::_customTextureLoader) {
texture = spine::_customTextureLoader(path);
}
if (!texture) {
texture = Director::getInstance()->getTextureCache()->addImage(path);
}
CCASSERT(texture != nullptr, "Invalid image");
texture->retain();

View File

@ -38,4 +38,10 @@
#include <spine/SkeletonAnimation.h>
#include <spine/SkeletonBatch.h>
namespace spine {
typedef cocos2d::Texture2D* (*CustomTextureLoader)(const char* path);
// set custom texture loader for _spAtlasPage_createTexture
void spAtlasPage_setCustomTextureLoader(CustomTextureLoader texLoader);
}
#endif /* SPINE_COCOS2DX_H_ */