закадровая прокрутка узла параллакса cclayers - PullRequest
0 голосов
/ 22 декабря 2011

Manage для прокрутки моего 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)];

}

1 Ответ

0 голосов
/ 22 декабря 2011

Вы можете установить свойство swallowsTouches ZoomController и посмотреть на TargetTouchDelegate для обработки более сложных событий касания.

...