Browse Source

Added property to control swipe pan speed

https://trello.com/c/TmG9SiIa
master
chrisgregan 10 years ago
parent
commit
1142d06ce8
  1. 14
      Assets/Fungus/Camera/Scripts/CameraController.cs
  2. 5
      Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs

14
Assets/Fungus/Camera/Scripts/CameraController.cs

@ -33,15 +33,16 @@ namespace Fungus
*/ */
public float cameraZ = -10f; public float cameraZ = -10f;
[HideInInspector]
public bool swipePanActive;
[HideInInspector] [HideInInspector]
public bool waiting; public bool waiting;
protected float fadeAlpha = 0f; protected float fadeAlpha = 0f;
// Swipe panning control // Swipe panning control
[HideInInspector]
public bool swipePanActive;
[HideInInspector]
public float swipeSpeedMultiplier = 1f;
protected View swipePanViewA; protected View swipePanViewA;
protected View swipePanViewB; protected View swipePanViewB;
protected Vector3 previousMousePos; protected Vector3 previousMousePos;
@ -426,7 +427,7 @@ namespace Fungus
* Activates swipe panning mode. * Activates swipe panning mode.
* The player can pan the camera within the area between viewA & viewB. * The player can pan the camera within the area between viewA & viewB.
*/ */
public virtual void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction) public virtual void StartSwipePan(View viewA, View viewB, float duration, float speedMultiplier, Action arriveAction)
{ {
Camera camera = GetCamera(); Camera camera = GetCamera();
if (camera == null) if (camera == null)
@ -436,6 +437,7 @@ namespace Fungus
swipePanViewA = viewA; swipePanViewA = viewA;
swipePanViewB = viewB; swipePanViewB = viewB;
swipeSpeedMultiplier = speedMultiplier;
Vector3 cameraPos = camera.transform.position; Vector3 cameraPos = camera.transform.position;
@ -503,8 +505,8 @@ namespace Fungus
if (camera != null) if (camera != null)
{ {
Vector3 cameraDelta = camera.ScreenToViewportPoint(delta); Vector3 cameraDelta = camera.ScreenToViewportPoint(delta);
cameraDelta.x *= -2f; cameraDelta.x *= -2f * swipeSpeedMultiplier;
cameraDelta.y *= -2f; cameraDelta.y *= -2f * swipeSpeedMultiplier;
cameraDelta.z = 0f; cameraDelta.z = 0f;
Vector3 cameraPos = camera.transform.position; Vector3 cameraPos = camera.transform.position;

5
Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs

@ -19,11 +19,14 @@ namespace Fungus
[Tooltip("Time to move the camera to a valid starting position between the two views")] [Tooltip("Time to move the camera to a valid starting position between the two views")]
public float duration = 0.5f; public float duration = 0.5f;
[Tooltip("Multiplier factor for speed of swipe pan")]
public float speedMultiplier = 1f;
public override void OnEnter() public override void OnEnter()
{ {
CameraController cameraController = CameraController.GetInstance(); CameraController cameraController = CameraController.GetInstance();
cameraController.StartSwipePan(viewA, viewB, duration, () => Continue() ); cameraController.StartSwipePan(viewA, viewB, duration, speedMultiplier, () => Continue() );
} }
public override string GetSummary() public override string GetSummary()

Loading…
Cancel
Save