1
我想讓用戶觸摸屏幕,我把這些觸摸的大小和位置,併爲他提供一個圖像「好像它」是他的指紋,但與幾乎相同的形狀和他的手指我需要模仿手指觸摸,繪製觸摸的印記
我實現了的touchesBegan功能與touchesMoves功能如下的大小(兩者都具有相同的碼)
,因爲它是所示的touchSize下面是實際的用戶觸摸到的尺寸屏幕和它保存的觸摸半徑,然後我創建了一個使用SKshapeNode和顏色的圓形形狀,並將其顯示在屏幕上
點它的顏色在這裏我感動,但是當我移動觸摸規模開始變大,我不能讓它吸取手指
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
/* Called when a touch begins*/
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
CGFloat touchSize = [[touch valueForKey:@"pathMajorRadius"] floatValue];
SKShapeNode *touchedLocation = [SKShapeNode shapeNodeWithCircleOfRadius:touchSize/4];
touchedLocation.fillColor = [SKColor whiteColor];
touchedLocation.position = location;
[self addChild:touchedLocation];
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
CGFloat touchSize = [[touch valueForKey:@"pathMajorRadius"] floatValue];
isScreenTouched = YES;
SKShapeNode *touchedLocation = [SKShapeNode shapeNodeWithCircleOfRadius:touchSize/4];
touchedLocation.fillColor = [SKColor whiteColor];
touchedLocation.position = location;
touchedLocation.name = @"AnamelPrint";
[self addChild:touchedLocation];
}
}
小混亂......如果你只是想要一個手指的印記,爲什麼你使用touchesMoved? – sangony
嗯,我是iOS的初學者。我使用了touchesMoved,因爲當我只使用touchesBegan時,它顯示出一個小圓形並且我希望它是手指的形狀 – Sara
您意識到屏幕實際上不能「讀取」指紋。我建議你拍一張指紋圖像並放置在觸摸位置,以模擬你正在嘗試做什麼。 – sangony