浏览代码

[c] Fixed rotation timeline handling in AnimationState. Fixed main.cpp missing a break

badlogic 8 年之前
父节点
当前提交
6fe1e8fa68
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. 5 5
      spine-c/spine-c/src/spine/AnimationState.c
  2. 2 0
      spine-sfml/example/main.cpp

+ 5 - 5
spine-c/spine-c/src/spine/AnimationState.c

@@ -433,6 +433,8 @@ void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline*
 	float total, diff;
 	int /*boolean*/ current, dir;
 
+	if (firstFrame) timelinesRotation[i] = 0;
+
 	if (alpha == 1) {
 		spTimeline_apply(timeline, skeleton, 0, time, 0, 0, 1, setupPose, 0);
 		return;
@@ -468,11 +470,7 @@ void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline*
 	r1 = setupPose ? bone->data->rotation : bone->rotation;
 	diff = r2 - r1;
 	if (diff == 0) {
-		if (firstFrame) {
-			timelinesRotation[i] = 0;
-			total = 0;
-		} else
-			total = timelinesRotation[i];
+		total = timelinesRotation[i];
 	} else {
 		float lastTotal, lastDiff;
 		diff -= (16384 - (int)(16384.499999999996 - diff / 360)) * 360;
@@ -581,6 +579,8 @@ void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEnt
 		current->mixingFrom = from;
 		current->mixTime = 0;
 
+		from->timelinesRotationCount = 0;
+
 		/* If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero. */
 		if (from->mixingFrom) current->mixAlpha *= MIN(from->mixTime / from->mixDuration, 1);
 	}

+ 2 - 0
spine-sfml/example/main.cpp

@@ -48,6 +48,7 @@ void callback (AnimationState* state, EventType type, TrackEntry* entry, Event*
 		break;
 	case ANIMATION_INTERRUPT:
 		printf("%d interrupt: %s\n", entry->trackIndex, animationName);
+		break;
 	case ANIMATION_END:
 		printf("%d end: %s\n", entry->trackIndex, animationName);
 		break;
@@ -56,6 +57,7 @@ void callback (AnimationState* state, EventType type, TrackEntry* entry, Event*
 		break;
 	case ANIMATION_DISPOSE:
 		printf("%d dispose: %s\n", entry->trackIndex, animationName);
+		break;
 	case ANIMATION_EVENT:
 		printf("%d event: %s, %s: %d, %f, %s\n", entry->trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
 				event->stringValue);