2013-03-24 84 views
2

paning我想用手勢我怎麼能做到這一點使用平移廣告牌,我已經修改了DemoMashUp這樣的:cocos3d廣告牌用手勢

- (void)dragBy: (CGPoint) aMovement atVelocity: (CGPoint) aVelocity 
{ 
    if (selectedNode == dieCube || selectedNode == texCubeSpinner) { 
     [self rotate: ((SpinningNode*)selectedNode) fromSwipeVelocity: aVelocity]; 
    } 

    if (selectedNode==marker) { 
     [self moveSelectedNode:marker fromSwipeMovement:aMovement]; 
    } 
} 

- (void)stopDragging 
{ 
    selectedNode = nil; 
} 

- (void)moveSelectedNode:(CC3Billboard*) aNode fromSwipeMovement: (CGPoint) swipeMovement 
{ 
    aNode.location=cc3v(swipeMovement.x, swipeMovement.y, aNode.location.z); 
} 

,但它不工作,當我接觸到的廣告牌就在前看不見

回答

2

我犯了一個新的方法moveSelectedNode 「DemoMashUpScene」 是這樣的:

-(void) touchEvent: (uint) touchType at: (CGPoint) touchPoint { 
    NSLog(@"\n\n*******************TOUCH EVEN CALLED************************\n\n"); 


    switch (touchType) { 
     case kCCTouchBegan: 
      [self pickNodeFromTouchEvent: touchType at: touchPoint]; 
      break; 
     case kCCTouchMoved: 

     if (selectedNode==marker||selectedNode==marker1||selectedNode==marker2||selectedNode==marker3||selectedNode==marker4||selectedNode==marker5) 
      { 


       [self moveSelectedNode:marker1 fromSwipeMovement:touchPoint]; 


      } 
      break; 
     case kCCTouchEnded: 

      selectedNode = nil; 
      break; 
     default: 
      break; 
    } 

    lastTouchEventPoint = touchPoint; 
    lastTouchEventTime = now; 
} 

-(void) moveSelectedNode: (CC3Billboard*) aNode fromSwipeMovement: (CGPoint) swipeMovement { 

    CC3Vector vector= CC3VectorMake(swipeMovement.x * 3, swipeMovement.y * 3, 0); 
    aNode.location=cc3v(aNode.location.x, aNode.location.y, 0.0); 
    aNode.location=CC3VectorAdd(aNode.location,vector);  
    CCLOG(@"%@",aNode.name); 
// NSLog(@"\n\n ******MOVING****%f_____%f*****____%f",vector.x,vector.y,vector.z); 


}