2014-12-07 88 views
1

在我的Cocos2d遊戲中,我將一個暫停按鈕添加到CCScene中。暫停按鈕是一個CCButton。問題是,當我按下按鈕時,不會調用該操作。我已經測試了主菜單上的按鈕,它工作正常。我嘗試使用control.block = ^(身份證發件人),它也沒有工作。我在init方法中調用addPauseButton方法。我想知道這個問題是否與物理節點有關。CCButton不會調用方法

-(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?"); 

} 

回答

2

前段時間我有這個相同的問題,並不能確定它。問題是UIGestureRecognizer阻止用戶觸摸被髮送到響應者鏈。檢查你的代碼,看看你是否使用UIGestureRecognizer。我還建議閱讀UIGestureRecognizer的Apple文檔。

+1

這是正確的答案非常感謝! – Asdrubal 2014-12-07 22:02:13