Q 개발 차전 사용하여 구현할 수 있습니다
을
Xcode에서 사용할 수있는 기존 효과입니까?
A : 없음
그러나 한 가지 방법은 "영화"제스처에서 CGVector을 만들 수 없을 것입니다. 그런 다음 벡터에 "flicking"인 물체에 충격을가하십시오. 다음은 SpriteKit과 함께 사용되지만 다른 프레임 워크에서는 "flick"제스처로부터 벡터를 얻는 원칙을 채택 할 수 있습니다.
typedef struct TouchData {
CGPoint point;
NSTimeInterval time;
} TouchData;
그리고 속성 - - 새총 효과가 마음에 오는
@property TouchData touchOriginData;
// Touch Handling
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// store the start data
for (UITouch *touch in touches) {
_touchOriginData.point = [touch locationInNode:self];
_touchOriginData.time = [touch timestamp];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// store the end data
TouchData touchEndData;
for (UITouch *touch in touches) {
touchEndData.point = [touch locationInNode:self];
touchEndData.time = touch.timestamp;
}
// calculate the impulse vector from TouchData structs
NSTimeInterval timeTaken = touchEndData.time - _touchOriginData.time;
CGFloat vector_x = (touchEndData.point.x - _touchOriginData.point.x)/timeTaken * FLICK_SCALAR;
CGFloat vector_y = (touchEndData.point.y - _touchOriginData.point.y)/timeTaken * FLICK_SCALAR;
CGVector impulseVector = CGVectorMake(vector_x, vector_y);
// fire projectile node
[self someMethodThatFiresWithVector:impulseVector];
}
우선
우리는 헬퍼 구조체가 필요합니다. – joels
당신이 기술하고있는 것이 물리 시뮬레이션 (가속도, 속도 등)에 가장 잘 설명되는 시나리오이므로 SpriteKit을 살펴볼 수 있습니다. SpriteKit은 많은 것을 구현할 수 있습니다. 그렇지 않으면, 나는 그것에 대해 구체적인 이름이 있다고는 생각하지 않는다. – user2105505