我有一个CClayer
名为 GridLayer 的类,我将手势识别器(平移、捏合和旋转)添加到视图中,它工作正常,但是如果我将一个CCMenuItem
粘贴到视图中,因此会受到旋转和捏合手势的影响,我的问题是谁实现了独立CCMenuitem
于视图大小、比例和位置。
//Adding Rotation Recognicer onEnter Method
self.rotationRecognicer =[[[UIRotationGestureRecognizer alloc]initWithTarget:self
action:@selector(rotate:)]autorelease];
[[[CCDirector sharedDirector] view] addGestureRecognizer:_rotationRecognicer];
//Adding CCMenuItem On Init Method
CCMenuItem *starMenuItem = [CCMenuItemImage
itemWithNormalImage:@"ButtonStar.png"
selectedImage:@"ButtonStarSel.png"
target:self
selector:@selector(starButtonTapped:)];
starMenuItem.position = ccp(60, 60);
CCMenu *starMenu = [CCMenu menuWithItems:starMenuItem, nil];
starMenu.position = CGPointZero;
[self addChild:starMenu];
//Rotation Method
- (void)rotate:(UIRotationGestureRecognizer *)gestureRecognizer
{
[self adjustAnchorPointForGestureRecognizer:gestureRecognizer];
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
[gestureRecognizer view].transform = CGAffineTransformRotate([[gestureRecognizer view] transform], [gestureRecognizer rotation]);
[gestureRecognizer setRotation:0];
}
}