2D Toolkit Forum
2D Toolkit => Support => Topic started by: amit.r007 on June 17, 2014, 11:22:25 am
-
Hi Unikron,
In my 2D game I have a circular sprite which I want to rotate as per touch input. I want to rotate that 2D sprite on z- Axis, say like a 2D Car steering (x and y fixed) according to the touch and drag of a finger/thumb.
Please help me regarding the same.
Thanks,
Amit
-
Any thoughts on this ?? :)
-
here is some touchScript (http://interactivelab.github.io/TouchScript/) code for panning
you could do something similar but change rotation instead of position maybe
private void HandlePanStateChanged(object s, TouchScript.Events.GestureStateChangeEventArgs e)
{
if (Utility.Paused) return;
Menu.Instance.Close();
switch (e.State)
{
case Gesture.GestureState.Began:
case Gesture.GestureState.Changed:
SimplePanGesture g = (SimplePanGesture)s;
if (g.LocalDeltaPosition != Vector3.zero)
{
GameCamera.transform.localPosition -= g.LocalDeltaPosition / GameCamera.ZoomFactor;
}
break;
case Gesture.GestureState.Ended:
Spring();
break;
}
}