Made 0 scale use "content scale factor". Commented drawOrder animation.

This commit is contained in:
NathanSweet 2013-10-30 14:25:16 +01:00
parent 284ac9a5be
commit 6862eec5af
6 changed files with 16 additions and 15 deletions

View File

@ -14,7 +14,8 @@
self = [super init];
if (!self) return nil;
animationNode = [CCSkeletonAnimation skeletonWithFile:@"spineboy.json" atlasFile:@"spineboy.atlas" scale:1];
// A scale of zero will use 1 / CC_CONTENT_SCALE_FACTOR().
animationNode = [CCSkeletonAnimation skeletonWithFile:@"spineboy.json" atlasFile:@"spineboy.atlas" scale:0];
[animationNode setMixFrom:@"walk" to:@"jump" duration:0.2f];
[animationNode setMixFrom:@"jump" to:@"walk" duration:0.4f];
[animationNode setDelegate:self];
@ -22,7 +23,7 @@
[animationNode addAnimationForTrack:0 name:@"jump" loop:NO afterDelay:0];
[animationNode addAnimationForTrack:0 name:@"walk" loop:YES afterDelay:0];
[animationNode addAnimationForTrack:0 name:@"jump" loop:YES afterDelay:4];
[animationNode setAnimationForTrack:1 name:@"drawOrder" loop:YES];
// [animationNode setAnimationForTrack:1 name:@"drawOrder" loop:YES];
animationNode.timeScale = 0.3f;
animationNode.debugBones = true;

View File

@ -90,7 +90,7 @@
if (!self) return nil;
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = scale;
json->scale = scale == 0 ? (1 / CC_CONTENT_SCALE_FACTOR()) : scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, [skeletonDataFile UTF8String]);
NSAssert(skeletonData, ([NSString stringWithFormat:@"Error reading skeleton data file: %@\nError: %s", skeletonDataFile, json->error]));
SkeletonJson_dispose(json);
@ -110,7 +110,7 @@
if (!_atlas) return 0;
SkeletonJson* json = SkeletonJson_create(_atlas);
json->scale = scale;
json->scale = scale == 0 ? (1 / CC_CONTENT_SCALE_FACTOR()) : scale;
SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, [skeletonDataFile UTF8String]);
NSAssert(skeletonData, ([NSString stringWithFormat:@"Error reading skeleton data file: %@\nError: %s", skeletonDataFile, json->error]));
SkeletonJson_dispose(json);

View File

@ -27,7 +27,7 @@ bool ExampleLayer::init () {
skeletonNode->addAnimation(0, "jump", false);
skeletonNode->addAnimation(0, "walk", true);
skeletonNode->addAnimation(0, "jump", true, 4);
skeletonNode->addAnimation(1, "drawOrder", true);
// skeletonNode->addAnimation(1, "drawOrder", true);
// skeletonNode->timeScale = 0.3f;
skeletonNode->debugBones = true;

View File

@ -92,7 +92,7 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scal
initialize();
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale;
json->scale = scale == 0 ? (1 / CCDirector::sharedDirector()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data.");
spSkeletonJson_dispose(json);
@ -107,7 +107,7 @@ CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, flo
CCAssert(atlas, "Error reading atlas file.");
spSkeletonJson* json = spSkeletonJson_create(atlas);
json->scale = scale;
json->scale = scale == 0 ? (1 / CCDirector::sharedDirector()->getContentScaleFactor()) : scale;
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, skeletonDataFile);
CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);

View File

@ -50,12 +50,12 @@ public:
bool premultipliedAlpha;
static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
static CCSkeleton* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
static CCSkeleton* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
CCSkeleton (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
CCSkeleton (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
virtual ~CCSkeleton ();

View File

@ -51,12 +51,12 @@ public:
spAnimationState* state;
static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData);
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
static CCSkeletonAnimation* createWithFile (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
CCSkeletonAnimation (spSkeletonData* skeletonData);
CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 1);
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 1);
CCSkeletonAnimation (const char* skeletonDataFile, spAtlas* atlas, float scale = 0);
CCSkeletonAnimation (const char* skeletonDataFile, const char* atlasFile, float scale = 0);
virtual ~CCSkeletonAnimation ();