Added getTextureAtlas method when not using AtlasAttachmentLoader.

This commit is contained in:
NathanSweet 2013-05-06 17:59:06 +02:00
parent 6bbce812f8
commit 3f3449ca99
4 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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;