【发布时间】:2011-07-16 12:14:46
【问题描述】:
我正在使用 Cocos2d 来渲染精灵,并使用 UIGestureRecognizers 来允许用户平移、旋转和缩放精灵。
我让每个人都使用如下代码单独工作:
UIPinchGestureRecognizer *pinchRecognizer = [[[UIPinchGestureRecognizer alloc] initWithTarget:layer action:@selector(handlePinchFrom:)] autorelease];
[viewController.view addGestureRecognizer:pinchRecognizer];
UIRotationGestureRecognizer *rotationRecognizer = [[[UIRotationGestureRecognizer alloc] initWithTarget:layer action:@selector(handleRotationFrom:)] autorelease];
[viewController.view addGestureRecognizer:rotationRecognizer];
但是,如果用户在旋转时将手指捏在一起,我想同时缩放和旋转精灵(例如,照片应用程序会这样做)。不幸的是,识别器似乎陷入了“旋转”或“捏合”模式,并且不会同时调用两个处理程序:(
所以,基本上,我想知道 - 这是否意味着我不能使用 UIGestureRecognizers?我可以组合两个识别器并在一个处理程序中执行所有操作吗?我是否必须将 UIGestureRecognizer 子类化为类似于“PinchAndRotateRecognizer”的东西。
帮助表示赞赏:)
【问题讨论】:
标签: iphone objective-c cocos2d-iphone