Domanda

I want to pan the billboard using using gestures how can i do that, i have modified the DemoMashUp like this:

 - (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);
}

but its not working and when i touch the billboard it disapears

È stato utile?

Soluzione

i made a new method moveSelectedNode "DemoMashUpScene" like this :

   -(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);


}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top