-
Notifications
You must be signed in to change notification settings - Fork 138
Description
I am creating a 2D game, and I am wanting to use touch screen gestures to change game cameras. I don't know if this is something that can be implemented easily. I have been working on this all afternoon, and I need some outside help. I am a complete noob to C#, so I may have a number of issues that would be problematic. I was thinking that I could use some code kinda like this to make this work:
public Camera camorig;
public Camera camleft;
public Camera camright;
void Update () {
CameraTransition cameraTransition = GameObject.FindObjectOfType<CameraTransition>();
if (cameraTransition == null)
Debug.LogWarning(@"CameraTransition not found.");
var recognizer = new TKSwipeRecognizer();
recognizer.gestureRecognizedEvent += ( r ) =>
{
Debug.Log( "swipe recognizer fired: " + r );
} ;
TouchKit.addGestureRecognizer( recognizer );
if (state == TKGestureRecognizerState.Recognized) {
if (completedSwipeDirection == TKSwipeDirection.Left) {
cameraTransition.DoTransition (CameraTransitionEffects.Fold, camorig, camleft, 1.0f);
} else if (completedSwipeDirection == TKSwipeDirection.Right) {
cameraTransition.DoTransition (CameraTransitionEffects.Fold, camorig, camright, 1.0f);
} else {
Debug.Log (@"Swipe not successful");
}
}
else {
Debug.Log (@"Gesture not recognized");
}
}
You can see that I am using another addon to facilitate transitions between cameras. Would something like this work, or am I completely off? I didn't know if I could use variables like "state" and "completedSwipeDirection" from the swipe recognizer, so that might be an issue. Because of that, I duplicated the recognizer and simply added this code to it, intending to attach the recognizer to my game object, but I wasn't able to attach it because it didn't derive from MonoDevelop. Any help would be much appreciated!
cstobler