Reputation: 89
In my app I am moving the ball according to the accelerometer movements but the ball not moved smoothly .I need to move the ball smoothly on view.How can i?
I used below statements by searching on google.but i didn't get the smooth object
delta.x = 0.01 * delta.x + (1.0 - 0.01) * acceleration.x;
delta.y = 0.01 * delta.y + (1.0 - 0.01) * acceleration.y;
Upvotes: 0
Views: 1001
Reputation: 533
use
[UIView beginAniations:@"AnimaionName" context:nil];
[UIView setAnimationDuration: 2.0f];
imageView.frame = CGRectMake(,,,);
[UIView commitAnimation];
This will provide smooth movement
Upvotes: 0
Reputation: 4500
Try :
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
point = CGPointMake(34*acceleration.x, -20*acceleration.y);
image.center = CGPointMake(image.center.x+point.x,image.center.y);
}
Upvotes: 1