0

How do you exactly use easing inside CCSequence?

Related to Using CCEaseOut together with CCSequence?

Community
  • 1
  • 1
Jonny
  • 15,955
  • 18
  • 111
  • 232

1 Answers1

0

here is an example. This brings back my mapNode to the left border, for example when a LHS menu is popped out. Move duration and acceleration are computed as a function of the expected displacement :

- (void)setLeftClamp:(float)leftClamp {

    _leftClamp = leftClamp;

    CGPoint currentPosition = self.mapNode.position;
    if (currentPosition.x > self.maxX) {
        // ease right back in position
        CGPoint delta         = ccp (self.maxX - currentPosition.x, 0);
        id      move          = [CCMoveBy actionWithDuration:[self moveDuration:delta] position:delta];
        id      ease          = [CCEaseIn actionWithAction:move rate:[self moveAcceleration:delta]];
        id      delay         = [CCDelayTime actionWithDuration:.1f];
        id      easeAndCenter = [CCSequence actions:ease, delay, [CCCallFunc actionWithTarget:self selector:@selector(onMoveComplete)], nil];
        [self.mapNode runAction:easeAndCenter];

        targetMapLocation_ = ccpAdd(self.mapNode.position, delta);
        mapDisplacement_   = delta;
        isMapMoving_       = YES;

    }

}
YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • That looks very much like what I already tried. Just adding the ease to the sequence - with one exception; the rate parameter. The ease does not work (just skips to end value right away) if rate is not specified. If rate is specified (I just set it to 1), it works. – Jonny Apr 05 '13 at 04:57