【发布时间】:2012-03-08 23:53:21
【问题描述】:
我创建了两个颜色层并将它们显示在屏幕上:
if( (self=[super init] )) {
self.isTouchEnabled = YES;
CGSize s = [[CCDirector sharedDirector] winSize];
CCLayerColor* layer1 = [CCLayerColor layerWithColor: ccc4(255, 255, 0, 80)
width: 100
height: 300];
layer1.position = ccp(s.width/3, s.height/2);
layer1.isRelativeAnchorPoint = YES;
[self addChild: layer1 z:1];
CCLayerColor* layer2 = [CCLayerColor layerWithColor: ccc4(0, 0, 255, 255)
width: 100
height: 300];
layer2.position = ccp((s.width/3)*2, s.height/2);
layer2.isRelativeAnchorPoint = YES;
[self addChild: layer2 z:1];
}
return self;
}
我想为每一层启用触摸,第 1 层和第 2 层,例如,如果用户触摸第 1 层(做某事),如果您触摸第 2 层(做其他事情)。我已经设置了触摸调度器,
-(void) registerWithTouchDispatcher
{
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:No swallowsTouches:YES];
}
之后我不知道该怎么办,我试图搜索 cocos2d 文档,但找不到任何东西谢谢!
【问题讨论】:
标签: ios cocoa-touch cocos2d-iphone