Skip to content

Commit b998b2f

Browse files
committed
fixing animations out of sync error.
1 parent e262077 commit b998b2f

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ - (void)runActionsForNode:(CCNode*)node sequenceProperty:(CCBSequenceProperty*)s
387387
CCActionSequence* seq = [CCActionSequence actionWithArray:actions];
388388
seq.tag = _animationManagerId;
389389
[seq startWithTarget:node];
390-
if(kf0.time>0 || _loop) { // Ensure Sync
390+
if(startFrame == 0 && _loop) { // Ensure Sync
391391
[seq step:0];
392392
[seq step:_runningSequence.time-kf0.time];
393393
}
@@ -476,6 +476,19 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
476476
NSDictionary* seqNodeProps = [seqs objectForKey:[NSNumber numberWithInt:seqId]];
477477

478478
NSMutableSet* seqNodePropNames = [NSMutableSet set];
479+
480+
// Reset nodes that have sequence node properties, build first keyframe action sequence.
481+
for (NSString* propName in seqNodeProps) {
482+
CCBSequenceProperty* seqProp = [seqNodeProps objectForKey:propName];
483+
[seqNodePropNames addObject:propName];
484+
485+
// Reset Node State to First KeyFrame
486+
[self setKeyFrameForNode:node sequenceProperty:seqProp tweenDuration:tweenDuration keyFrame:0];
487+
488+
// Build First Key Frame Sequence
489+
[self runActionsForNode:node sequenceProperty:seqProp tweenDuration:tweenDuration startKeyFrame:0];
490+
}
491+
479492

480493
if(_lastSequence.sequenceId!=seqId) {
481494
_loop = NO;
@@ -495,17 +508,7 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
495508
}
496509
}
497510

498-
// Reset nodes that have sequence node properties, build first keyframe action sequence.
499-
for (NSString* propName in seqNodeProps) {
500-
CCBSequenceProperty* seqProp = [seqNodeProps objectForKey:propName];
501-
[seqNodePropNames addObject:propName];
502-
503-
// Reset Node State to First KeyFrame
504-
[self setKeyFrameForNode:node sequenceProperty:seqProp tweenDuration:tweenDuration keyFrame:0];
505-
506-
// Build First Key Frame Sequence
507-
[self runActionsForNode:node sequenceProperty:seqProp tweenDuration:tweenDuration startKeyFrame:0];
508-
}
511+
509512

510513
}
511514

0 commit comments

Comments
 (0)