mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-09 16:48:43 +08:00
[cocos2dx] allow load custom atlas texture in _spAtlasPage_createTexture for CocosCreator (#1018)
This commit is contained in:
parent
77221b4cee
commit
041b6ddb00
@ -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();
|
||||
|
||||
|
||||
@ -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_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user