在我的Cocos2d游戏中,我向CCScene添加了一个暂停按钮。暂停按钮是CCButton。问题在于,当按下我的按钮时,不会调用该动作。我已经测试了主菜单上的按钮,它工作正常。我尝试使用control.block = ^(id sender),但它也不起作用。我在init方法中调用addPauseButton方法。我想知道问题是否与物理节点有关。
-(void)addPauseButton
{
CCSpriteFrame *pauseNormalImage = [CCSpriteFrame frameWithImageNamed:@"pause.png"];
CCSpriteFrame *pauseHighlightedImage = [CCSpriteFrame frameWithImageNamed:@"pause_selected.png"];
CCButton *btnPause = [CCButton buttonWithTitle:nil
spriteFrame:pauseNormalImage
highlightedSpriteFrame:pauseHighlightedImage
disabledSpriteFrame:nil];
btnPause.positionType = CCPositionTypeNormalized;
btnPause.position = ccp(0.85f, 0.85f);
[btnPause setTarget:self selector:@selector(onbtnPauseTapped:)];
[self addChild:btnPause z:10000];
}
- (void)onbtnPauseTapped:(id)sender
{
NSLog(@"Working?");
}
我前一段时间也遇到过同样的问题,无法解决。问题在于UIGestureRecognizer
阻止用户触摸被发送到响应者链。检查您的代码以查看是否使用UIGestureRecognizer
。我还建议阅读UIGestureRecognizer的Apple文档。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句