Cocos2d .isTouchEnabled不会调用单触方法

时间:2012-05-20 21:28:07

标签: ios cocos2d-iphone

在Cocos2d中,当使用self.isTouchEnabled启用触摸时,我可以使用这样的方法:

-(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

但是,出于某种原因,这个不起作用:

-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event

为什么?

2 个答案:

答案 0 :(得分:1)

我还没有看到你的代码所以我说不出来但是你注册了

      CCTouchDispatcher

如何注册:

       [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

如何取消注册/删除以节省内存:

[[CCTouchDispatcher sharedDispatcher] removeDelegate:self];

答案 1 :(得分:0)

阅读有关触摸事件的文档。一切都在那里解释, http://www.cocos2d-iphone.org/wiki/doku.php/tips:touchdelegates