我创建了一个NSUInteger,它在Touches Moved方法中移动了每个像素的增量。但是增量不一致。看起来快速移动手指会慢慢增加手数,而慢慢移动手指会快速增加手数。
基本上我创造了一个墨水瓶效果,因此在屏幕上绘图会减少墨水与手指的移动一致,但是不同的绘图速度,这不会总是相同。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
SKLabelNode *touchedNode = (SKLabelNode *)[self nodeAtPoint:positionInScene];
pathToDraw = CGPathCreateMutable();
CGPathMoveToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode = [[SKShapeNode alloc] init];
lineNode.path = pathToDraw;
[_gameNode addChild:lineNode];
}
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
CGPathAddLineToPoint(pathToDraw, NULL, positionInScene.x, positionInScene.y);
lineNode.path = pathToDraw;
lineNode.name = lineNodeCategoryName;
lineNode.physicsBody = [SKPhysicsBody bodyWithEdgeChainFromPath:pathToDraw];
lineNode.physicsBody.categoryBitMask = lineNodeCategory;
lineNode.physicsBody.contactTestBitMask = bubble1Category|bubble2Category|bubble3Category|bubble4Category|bubble5Category;
lineNode.physicsBody.collisionBitMask = ballCategory;
lineNode.physicsBody.dynamic = YES;
lineNode.strokeColor = [SKColor blackColor];
lineNode.glowWidth = 3.0;
testNumber ++;
testLabel.text = [NSString stringWithFormat:@"%lu",(unsigned long)testNumber];
}
答案 0 :(得分:0)
touchesMoved:withEvent:
。您无法依赖此方法调用的次数来检测远用户手指的移动方式。
您应该尝试依靠手指在两个事件之间移动的距离来增加您的测试编号。