我想缩放到触摸位置,但这段代码总是缩放到屏幕中心。
-(id)init{
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action: @selector(handleDoubleTapFrom:)];
doubleTap.numberOfTapsRequired = 2;
doubleTap.numberOfTouchesRequired = 1;
[[[CCDirector sharedDirector] view] addGestureRecognizer:doubleTap];
}
- (void)handleDoubleTapFrom:(UITapGestureRecognizer *)recognizer {
//CGPoint touchLocation = [recognizer locationInView:[[CCDirector sharedDirector]view] ];
if(!isGameFinished){
if(zoomPerformed == NO ) {
id zoomIn = [CCScaleTo actionWithDuration:1.0f scale:2];
id sequence = [CCSequence actions:zoomIn, nil];
[self runAction:sequence];
zoomPerformed = YES;
}else{
id zoomOut = [CCScaleTo actionWithDuration:1.0f scale:1.0f];
id sequence = [CCSequence actions:zoomOut, nil];
[self runAction:sequence];
zoomPerformed = NO;
}
}
}
如何更改缩放原点?我搜索了,但没有一个方法奏效。