我想使用手势平移广告牌我该怎么做,我修改了这样的演示MashUp:
- (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);
}
但它不起作用,当我触摸广告牌时它消失了
答案 0 :(得分: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);
}