Hello
I'm making an eBook reader for the iPhone. I have made a page-turn with CABasicAnimation and it's working great. Now I want to do the page-turn "manually" by using the x-coordinate when your finger moves along the screen. I've achieve that, but it needs some tweaking to feel more "real". Because of the 3D effect (defined by transform.m14) the right side of the view does not follow the x-coordinate. If transform.m14 is commented out, the right side of the view follows x perfect.
Some code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if (self.view.layer.anchorPoint.x != 0.0f) {
self.view.layer.anchorPoint = CGPointMake(0.0f, 0.5f);
self.view.center = CGPointMake(self.view.center.x - self.view.bounds.size.width/2.0f, self.view.center.y);
}
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self.view];
float pct = location.x / 320.0f;
float rad = acosf(pct);
CATransform3D transform = CATransform3DMakeRotation(-rad, 0.0f, -1.0f, 0.0f);
transform.m14 = (1.0 / -2000) * acosf(pct);
self.view.layer.transform = transform;
}
I'm not that strong with (3D)geometry, but I guess that rad needs to compensate for the 3D projectory, but how?
Can you help?