梦过来蒙过去,

}elseif (self.panGesture.state == UIGestureRecognizerStateEnded)

    {

        endPoint = [self.panGesturelocationInView:self.moveView];

        CGPoint velocity = [self.panGesture velocityInView:self.moveView];

         vMax = sqrtf((velocity.x * velocity.x) + (velocity.y * velocity.y));

         aVelocity = 1000.0;

         useTime = vMax/aVelocity;

        [UIViewanimateWithDuration:useTimedelay:0options:UIViewAnimationOptionCurveEaseOutanimations:^{

            [self decelerateSetup];

        } completion:nil];

       [self.panGesturesetTranslation:CGPointMake(0, 0) inView:self.moveView];

}

 

//匀减速

-(void)decelerateSetup

{

    [timerinvalidate];

    timer = Nil;

    timer = [NSTimerscheduledTimerWithTimeInterval:0.001target:selfselector:@selector(decelerate:) userInfo:Nilrepeats:YES];

}

 

-(void)decelerate:(id)sender

{

    usedTime = usedTime + 0.001;

    CGFloat v1 = vMax - aVelocity * usedTime;

  

    CGFloat passRoad = (vMax * vMax - v1 * v1)/(2*aVelocity);//代表弧度

    currentRadius = passRoad/320*2;//半径是 320

 

    currentRadius = passRoad/M_PI*2;

 

//    if (endPoint.x > beginPoint.x) {

//        currentRadius = -currentRadius;

//    }

 

    if (v1 <= 0) {

        [timer invalidate];

        timer = Nil;

        useTime = 0;

        usedTime= 0;

        [[SoundManagershareSoundManager]stopPlay];

    }else{

        self.moveView.transform = CGAffineTransformMakeRotation(currentRadius);

    }

}

posted @ 2014-04-09 16:45  路在脚下,  阅读(171)  评论(0编辑  收藏  举报