变焦后灵魂不会被触及

时间:2011-05-05 11:10:16

标签: cocos2d-iphone

当我使用- (void)makepinch:(UIPinchGestureRecognizer *)pinch功能时,我的屏幕会变焦但在此之后我无法触及我的精灵。

任何人都可以有一个想法,我怎样才能在缩放后移动我的精灵。

这是我的缩放功能代码

- (void)makepinch:(UIPinchGestureRecognizer *)pinch {

    if([pinch state] == UIGestureRecognizerStateBegan) {
        // Reset the last scale, necessary if there are multiple objects with different scales
        lastScale = [pinch scale];
    }

    if ([pinch state] == UIGestureRecognizerStateBegan ||
        [pinch state] == UIGestureRecognizerStateChanged) {

        CGFloat currentScale = [[[pinch view].layer valueForKeyPath:@"transform.scale"] floatValue];

        // Constants to adjust the max/min values of zoom
        const CGFloat kMaxScale = 1.4;
        const CGFloat kMinScale = 1.0;

        CGFloat newScale = 1 -  (lastScale - [pinch scale]); // new scale is in the range (0-1)
        newScale = MIN(newScale, kMaxScale / currentScale);
        newScale = MAX(newScale, kMinScale / currentScale);
        CGAffineTransform transform = CGAffineTransformScale([[pinch view] transform], newScale, newScale);
        [pinch view].transform = transform;

        lastScale = [pinch scale];  // Store the previous scale factor for the next pinch gesture call
    }
}

0 个答案:

没有答案