管理滚动我的CCLayers视差节点,但我如何设置滚动的边界?
使用:- (void)registerWithTouchDispatcher {
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:1 swallowsTouches:NO];
}
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
return YES;
}
-(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint touchLocation = [touch locationInView: [touch view]];
CGPoint prevLocation = [touch previousLocationInView: [touch view]];
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
prevLocation = [[CCDirector sharedDirector] convertToGL: prevLocation];
CGPoint diff = ccpSub(touchLocation,prevLocation);
CCNode *node = [self getChildByTag:kTagNode];
CGPoint currentPos = [node position];
[node setPosition: ccpAdd(currentPos, diff)];
}
你可以设置ZoomController的swallowsTouches属性,并查看TargetTouchDelegate来处理更复杂的触摸事件