Преглед изворни кода

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

NathanSweet пре 12 година
родитељ
комит
6862eec5af

+ 3 - 2
spine-cocos2d-iphone/example/ExampleLayer.m

@@ -14,7 +14,8 @@
 	self = [super init];
 	self = [super init];
 	if (!self) return nil;
 	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:@"walk" to:@"jump" duration:0.2f];
 	[animationNode setMixFrom:@"jump" to:@"walk" duration:0.4f];
 	[animationNode setMixFrom:@"jump" to:@"walk" duration:0.4f];
 	[animationNode setDelegate:self];
 	[animationNode setDelegate:self];
@@ -22,7 +23,7 @@
 	[animationNode addAnimationForTrack:0 name:@"jump" loop:NO afterDelay:0];
 	[animationNode addAnimationForTrack:0 name:@"jump" loop:NO afterDelay:0];
 	[animationNode addAnimationForTrack:0 name:@"walk" loop:YES afterDelay:0];
 	[animationNode addAnimationForTrack:0 name:@"walk" loop:YES afterDelay:0];
 	[animationNode addAnimationForTrack:0 name:@"jump" loop:YES afterDelay:4];
 	[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.timeScale = 0.3f;
 	animationNode.debugBones = true;
 	animationNode.debugBones = true;
 
 

+ 2 - 2
spine-cocos2d-iphone/src/spine/CCSkeleton.m

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

+ 1 - 1
spine-cocos2dx/example/Classes/ExampleLayer.cpp

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

+ 2 - 2
spine-cocos2dx/src/spine/CCSkeleton.cpp

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

+ 4 - 4
spine-cocos2dx/src/spine/CCSkeleton.h

@@ -50,12 +50,12 @@ public:
 	bool premultipliedAlpha;
 	bool premultipliedAlpha;
 
 
 	static CCSkeleton* createWithData (spSkeletonData* skeletonData, bool ownsSkeletonData = false);
 	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 (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 ();
 	virtual ~CCSkeleton ();
 
 

+ 4 - 4
spine-cocos2dx/src/spine/CCSkeletonAnimation.h

@@ -51,12 +51,12 @@ public:
 	spAnimationState* state;
 	spAnimationState* state;
 
 
 	static CCSkeletonAnimation* createWithData (spSkeletonData* skeletonData);
 	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 (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 ();
 	virtual ~CCSkeletonAnimation ();