タップやダブルタップなどのgestureに関する実装と設定。
メモとして、APIリファレンスから、そのまま引用。
http://www.kobold2d.com/display/KKDOC/KKInput+Gestures#KKInputGestures-KKInputGestureRecognizerSupport
見直しながら、使えるようになりましょう、自分。
適当な訳をメモをかねて勉強のために書きましたが、あくまで適当です。間違えていたら、ご愛敬。よかったら教えて下さい。
KKInput Gesture Recognizer Support
KKInput supports all built-in UIGestureRecognizer gestures:
The Tap, Double-Tap and Swipe gestures are discrete events that are true only during the frame the gesture was recognized. All other gestures are continuous, meaning they continue to update their state until the gesture ends.タップとダブルタップとスワイプは、gestureが認識されたフレーム内でのみtrueで独立したイベントだと。
|
CGPoint pos;KKInput* input =[KKInput sharedInput];
pos=input.gestureTapLocation;
pos=input.gestureDoubleTapLocation;
など、と。
Discrete Gestures: Tap, Double-Tap and Swipe
The Tap, Double-Tap and Swipe gestures are discrete, ie they're only true in the frame they happened. Therefore they can only be checked with "ThisFrame" properties: タップとダブルタップとスワイプは、独立したgestureであるから、"ThisFrame"プロパティでのみチェック可能、と。
Only when a "ThisFrame" property is true will the corresponding gestureXXXLocation property contain a meaningful location. "ThisFrame"プロパティがtrueになったときのみ、関連のgestureXXXLocationプロパティが、意味のある位置を格納する、と。
Continuous Gestures: LongPress, Pan, Rotation and Pinch
All continuous gestures have a gestureXXXBegan property which is true the moment the gesture was first recognized, and stays true until the gesture ends or is cancelled. 全ての継続的gestureがgestureXXXBeganプロパティでtrueになるのは、gestureが最初に認識され、gestureが終わるまでtrueでいるか、もしくはcancelledになるまでtrueでいる場合である、と。(XXXって何かと思ったら、Pan,とかLongPressのことね。)(ま、長押しとかパンとかが、押しっぱなしであればtrueだよ、ということか。)
|
Only while the "Began" property is true will the corresponding gestureXXXLocation property contain a meaningful location.(Beganプロパティがtrueの場合だけ、、関連のgestureXXXLocationプロパティが意味のある位置を格納する、と。)
Swipe Gesture Properties
The swipe gesture has an additional property gestureSwipeDirection of type KKSwipeGestureDirectionwith which you can determine the direction of the swipe: right, left, up or down.(KKSwipeGestureDirectionで、スワイプ方向についての処理を設定しておける、と。)
Pan Gesture Properties
The Pan gesture has two extra properties gesturePanTranslation and gesturePanVelocity.The translation is a CGPoint that contains how far, in points, the finger has moved relative to the point where the Pan gesture began (gesturePanVelocityは、パンのgestureが始まった位置からどのぐらい離れたかのプロパティを持つ、と。).The velocity is a CGPoint that tells you how fast the finger is currently moving across the screen, in points per frame.(gesturePanVelocityでは、どのぐらい指がスクリーン上を早く動いているかを、フレームごとにCGPointとして取得、と。)
You can also modify the gesturePanTranslation property. If you do so, the gesturePanVelocity property is reset.
Rotation Gesture Properties
The Rotation gesture knows two exclusive properties gestureRotationAngle andgestureRotationVelocity.(AngleとVelocity、角度と速度のプロパティを持つ、と。) The angle is is the current rotation angle, in degrees (0-360). You can directly assign the angle to a node's direction property. The velocity tells you how fast the user is performing the rotation gesture, in degrees per frame.
You can also modify the gestureRotationAngle property. If you do so, the gestureRotationVelocityproperty is reset.
Pinch Gesture Properties
The Pinch gesture has two properties gesturePinchScale and gesturePinchVelocity(PinchScaleとPinchVelocityの二つのプロパティ。). Scale is the relative scale factor of the two fingers(二本指が離れるか、近寄るか), it increases the further the two fingers move apart, it decreases the closer they move towards each other. The scale property can be directly assigned to a node's scaleproperty. The velocity is how fast the fingers are moving towards or away from each other, in scale factor per frame.
You can also modify the input.gesturePinchScale property. If you do so, the input.gesturePinchVelocityproperty is reset.
Cancelling a Continuous Gesture Recognizer
If you want to ignore a continuous gesture after it began, you can cancel it simply by disabling and re-enabling the gesture like this: (継続的なgestureを無視させたい場合、ね。)
Note that this will release the previous gesture recognizer and allocate a new one, so you should avoid doing that every frame.
Accessing the underlying UIGestureRecognizer objects
As of Kobold2D v1.0.2 KKInput has the following properties with which you can gain access to the UIGestureRecognizer instances used by KKInput. This allows you to use all of the gesture recognizer features supported by UIGestureRecognizer and concrete subclasses, since KKInput only exposes the most frequently needed features.
Note that these properties may return nil if the gesture recognizer is not enabled.
You should not retain these properties! The gesture recognizers are retained by KKInput until you disable the gesture. Once you re-enable the gesture, a new gesture recognizer is allocated which would then be used rather than your retained instance.
In Mac OS X builds these properties are declared to be of type id and will always return nil.
| |||||||
Labels:
|
0 件のコメント:
コメントを投稿