Skip to content

Commit ee80ab9

Browse files
committed
Merge pull request #836 from jtwigg/develop
Animation Sync Errors.
2 parents 590c404 + ac77f99 commit ee80ab9

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ - (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(kf0.time > 0 || _loop) { // Ensure Sync
391391
[seq step:0];
392-
[seq step:_runningSequence.time-kf0.time];
392+
[seq step:_runningSequence.time-kf0.time - _runningSequence.tween];
393393
}
394394
[_currentActions addObject:seq];
395395
}
@@ -464,6 +464,7 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
464464
// Set the running scene
465465
_runningSequence = [self sequenceFromSequenceId:seqId];
466466
_runningSequence.time = 0.0f;
467+
_runningSequence.tween = tweenDuration;
467468

468469
[self addSequenceCallBacks:seqId tweenDuration:tweenDuration startTime:0];
469470

@@ -476,6 +477,19 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
476477
NSDictionary* seqNodeProps = [seqs objectForKey:[NSNumber numberWithInt:seqId]];
477478

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

480494
if(_lastSequence.sequenceId!=seqId) {
481495
_loop = NO;
@@ -495,17 +509,7 @@ - (void)runAnimationsForSequenceId:(int)seqId tweenDuration:(float) tweenDuratio
495509
}
496510
}
497511

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-
}
512+
509513

510514
}
511515

cocos2d-ui/CCBReader/CCBSequence.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@property (nonatomic,assign) int sequenceId;
3636
@property (nonatomic,assign) int chainedSequenceId;
3737
@property (nonatomic,assign) int loops; // @todo
38+
@property (nonatomic,assign) float tween;
3839

3940
// Channels
4041
@property (nonatomic,strong) CCBSequenceProperty* callbackChannel;

cocos2d-ui/CCBReader/CCBsequence.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ - (id)init
4242

4343
_callbackChannel = nil;
4444
_soundChannel = nil;
45+
_tween = 0.0f;
4546

4647
return self;
4748
}

0 commit comments

Comments
 (0)