diff --git a/spine-cocos2d-iphone/src/spine/CCSkeleton.h b/spine-cocos2d-iphone/src/spine/CCSkeleton.h index e18d9aaf9..e17a94436 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeleton.h +++ b/spine-cocos2d-iphone/src/spine/CCSkeleton.h @@ -53,6 +53,8 @@ Draws a skeleton. - (id) initWithFile:(NSString*)skeletonDataFile atlas:(Atlas*)atlas scale:(float)scale; - (id) initWithFile:(NSString*)skeletonDataFile atlasFile:(NSString*)atlasFile scale:(float)scale; +- (CCTextureAtlas*) getTextureAtlas:(RegionAttachment*)regionAttachment; + // --- Convenience methods for common Skeleton_* functions. - (void) updateWorldTransform; diff --git a/spine-cocos2d-iphone/src/spine/CCSkeleton.m b/spine-cocos2d-iphone/src/spine/CCSkeleton.m index 780453ace..1ee7c78b5 100644 --- a/spine-cocos2d-iphone/src/spine/CCSkeleton.m +++ b/spine-cocos2d-iphone/src/spine/CCSkeleton.m @@ -143,7 +143,7 @@ Slot* slot = _skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; RegionAttachment* attachment = (RegionAttachment*)slot->attachment; - CCTextureAtlas* regionTextureAtlas = (CCTextureAtlas*)attachment->rendererObject; + CCTextureAtlas* regionTextureAtlas = [self getTextureAtlas:attachment]; if (regionTextureAtlas != textureAtlas) { if (textureAtlas) { [textureAtlas drawQuads]; @@ -200,6 +200,10 @@ } } +- (CCTextureAtlas*) getTextureAtlas:(RegionAttachment*)regionAttachment { + return (CCTextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject; +} + - (CGRect) boundingBox { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = self.scaleX; diff --git a/spine-cocos2dx/src/spine/CCSkeleton.cpp b/spine-cocos2dx/src/spine/CCSkeleton.cpp index 4f56ff7e2..831514108 100644 --- a/spine-cocos2dx/src/spine/CCSkeleton.cpp +++ b/spine-cocos2dx/src/spine/CCSkeleton.cpp @@ -135,7 +135,7 @@ void CCSkeleton::draw () { Slot* slot = skeleton->slots[i]; if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue; RegionAttachment* attachment = (RegionAttachment*)slot->attachment; - CCTextureAtlas* regionTextureAtlas = (CCTextureAtlas*)((AtlasRegion*)attachment->rendererObject)->page->rendererObject; + CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment); if (regionTextureAtlas != textureAtlas) { if (textureAtlas) { textureAtlas->drawQuads(); @@ -192,6 +192,10 @@ void CCSkeleton::draw () { } } +CCTextureAtlas* CCSkeleton::getTextureAtlas (RegionAttachment* regionAttachment) const { + return (CCTextureAtlas*)((AtlasRegion*)regionAttachment->rendererObject)->page->rendererObject; +} + CCRect CCSkeleton::boundingBox () { float minX = FLT_MAX, minY = FLT_MAX, maxX = FLT_MIN, maxY = FLT_MIN; float scaleX = getScaleX(); diff --git a/spine-cocos2dx/src/spine/CCSkeleton.h b/spine-cocos2dx/src/spine/CCSkeleton.h index 8fd03bc0f..7b316f825 100644 --- a/spine-cocos2dx/src/spine/CCSkeleton.h +++ b/spine-cocos2dx/src/spine/CCSkeleton.h @@ -83,7 +83,8 @@ public: protected: CCSkeleton (); - void setSkeletonData (SkeletonData *skeletonData, bool ownsSkeletonData); + void setSkeletonData (SkeletonData* skeletonData, bool ownsSkeletonData); + cocos2d::CCTextureAtlas* getTextureAtlas (RegionAttachment* regionAttachment) const; private: bool ownsSkeletonData;