您如何在 CCSequence 中准确使用缓动?
问问题
789 次
1 回答
0
这是一个例子。这会将我的 mapNode 带回左边框,例如当弹出 LHS 菜单时。移动持续时间和加速度计算为预期位移的函数:
- (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;
}
}
于 2013-04-05T02:48:19.970 回答