移动sneakyjoystick时按钮无法点击 - Cocos2D Objective-c

时间:2014-01-05 11:55:52

标签: ios objective-c cocos2d-iphone

我已经在我的游戏中实现了偷偷摸摸/偷偷摸摸的文件,我已经制作了操纵杆。我还添加了一个按钮CCMenuItem

- (void)initJoystick {
SneakyJoystickSkinnedBase *joystickBase = [[SneakyJoystickSkinnedBase alloc] init];

joystickBase.backgroundSprite = [CCSprite spriteWithFile:@"base.png"];
joystickBase.thumbSprite = [CCSprite spriteWithFile:@"joystick.png"];
joystickBase.joystick = [[SneakyJoystick alloc] initWithRect:CGRectMake(0, 0, 128, 128)];

joystickBase.position = ccp(90, 90);

[self addChild:joystickBase z:1000];

leftJoystick = [joystickBase.joystick retain];


CCLabelTTF *shootLabel = [[CCLabelTTF alloc] initWithString:@"Shoot" fontName:@"helvetica" fontSize:32.0];
CCMenuItem *shootItem = [CCMenuItemLabel itemWithLabel:shootLabel target:self selector:@selector(shootTapped)];
shootItem.color = ccORANGE;
CCMenu *menu = [CCMenu menuWithItems:shootItem, nil];
menu.position = ccp(500, 25);
[self addChild:menu z:1000];
}

操纵杆工作正常但在我移动时按钮无法识别任何按下。当我有CCMenuItems而不是操纵杆时,另一个按钮工作正常但操纵杆没有。那么熟悉偷偷摸摸文件的人还是有人知道如何同时进行两次点击?

1 个答案:

答案 0 :(得分:0)

您可能没有为视图/窗口启用多点触控。[1]

类似的东西:

[view setMultipleTouchEnabled:YES];

另外,see this answer

[1] https://github.com/cocos2d/cocos2d-iphone/blob/develop-v2/tests/TouchesTest/TouchesDemoAppDelegate.m#L19