Browse Source

Renamed ManualPan to SwipePan

master
chrisgregan 11 years ago
parent
commit
5d4ceaa170
  1. BIN
      Assets/Fungus/Prefabs/Game.prefab
  2. 44
      Assets/Fungus/Scripts/CameraController.cs
  3. 14
      Assets/Fungus/Scripts/Commands/CameraCommands.cs
  4. 24
      Assets/Fungus/Scripts/Game.cs
  5. 16
      Assets/Fungus/Scripts/GameController.cs
  6. BIN
      Assets/FungusExample/Scenes/Example.unity
  7. 2
      Assets/FungusExample/Scripts/MenuRoom.cs
  8. 4
      Assets/FungusExample/Scripts/ParallaxRoom.cs

BIN
Assets/Fungus/Prefabs/Game.prefab

Binary file not shown.

44
Assets/Fungus/Scripts/CameraController.cs

@ -14,9 +14,9 @@ namespace Fungus
{
Game game;
// Manual panning control
View manualPanViewA;
View manualPanViewB;
// Swipe panning control
View swipePanViewA;
View swipePanViewB;
Vector3 previousMousePos;
class CameraView
@ -39,7 +39,7 @@ namespace Fungus
public void FadeToView(View view, float fadeDuration, Action fadeAction)
{
game.manualPanActive = false;
game.swipePanActive = false;
// Fade out
Fade(0f, fadeDuration / 2f, delegate {
@ -87,7 +87,7 @@ namespace Fungus
*/
public void CenterOnSprite(SpriteRenderer spriteRenderer)
{
game.manualPanActive = false;
game.swipePanActive = false;
Sprite sprite = spriteRenderer.sprite;
Vector3 extents = sprite.bounds.extents;
@ -104,7 +104,7 @@ namespace Fungus
*/
public void PanToPosition(Vector3 targetPosition, float targetSize, float duration, Action arriveAction)
{
game.manualPanActive = false;
game.swipePanActive = false;
if (duration == 0f)
{
@ -207,7 +207,7 @@ namespace Fungus
*/
public void PanToPath(View[] viewList, float duration, Action arriveAction)
{
game.manualPanActive = false;
game.swipePanActive = false;
List<Vector3> pathList = new List<Vector3>();
@ -257,22 +257,22 @@ namespace Fungus
}
/**
* Activates manual panning mode.
* Activates swipe panning mode.
* The player can pan the camera within the area between viewA & viewB.
*/
public void StartManualPan(View viewA, View viewB, float duration, Action arriveAction)
public void StartSwipePan(View viewA, View viewB, float duration, Action arriveAction)
{
manualPanViewA = viewA;
manualPanViewB = viewB;
swipePanViewA = viewA;
swipePanViewB = viewB;
Vector3 cameraPos = Camera.main.transform.position;
Vector3 targetPosition = CalcCameraPosition(cameraPos, manualPanViewA, manualPanViewB);
float targetSize = CalcCameraSize(cameraPos, manualPanViewA, manualPanViewB);
Vector3 targetPosition = CalcCameraPosition(cameraPos, swipePanViewA, swipePanViewB);
float targetSize = CalcCameraSize(cameraPos, swipePanViewA, swipePanViewB);
PanToPosition(targetPosition, targetSize, duration, delegate {
game.manualPanActive = true;
game.swipePanActive = true;
if (arriveAction != null)
{
@ -282,13 +282,13 @@ namespace Fungus
}
/**
* Deactivates manual panning mode.
* Deactivates swipe panning mode.
*/
public void StopManualPan()
public void StopSwipePan()
{
game.manualPanActive = false;
manualPanViewA = null;
manualPanViewB = null;
game.swipePanActive = false;
swipePanViewA = null;
swipePanViewB = null;
}
/**
@ -306,7 +306,7 @@ namespace Fungus
void Update()
{
if (!game.manualPanActive)
if (!game.swipePanActive)
{
return;
}
@ -340,8 +340,8 @@ namespace Fungus
cameraPos += cameraDelta;
Camera.main.transform.position = CalcCameraPosition(cameraPos, manualPanViewA, manualPanViewB);
Camera.main.orthographicSize = CalcCameraSize(cameraPos, manualPanViewA, manualPanViewB);
Camera.main.transform.position = CalcCameraPosition(cameraPos, swipePanViewA, swipePanViewB);
Camera.main.orthographicSize = CalcCameraSize(cameraPos, swipePanViewA, swipePanViewB);
}
// Clamp camera position to region defined by the two views

14
Assets/Fungus/Scripts/Commands/CameraCommands.cs

@ -154,16 +154,16 @@ namespace Fungus
}
/**
* Switches on manual pan mode.
* Switches on swipe panning mode.
* This allows the player to swipe the screen to pan around a region defined by 2 views.
*/
public class StartManualPan : CommandQueue.Command
public class StartSwipePan : CommandQueue.Command
{
View viewA;
View viewB;
float duration;
public StartManualPan(View _viewA, View _viewB, float _duration)
public StartSwipePan(View _viewA, View _viewB, float _duration)
{
if (_viewA == null ||
_viewB == null)
@ -183,7 +183,7 @@ namespace Fungus
game.waiting = true;
game.cameraController.StartManualPan(viewA, viewB, duration, delegate {
game.cameraController.StartSwipePan(viewA, viewB, duration, delegate {
game.waiting = false;
@ -196,15 +196,15 @@ namespace Fungus
}
/**
* Switches off manual pan mode.
* Switches off pan-to-swipe mode.
*/
public class StopManualPan : CommandQueue.Command
public class StopSwipePan : CommandQueue.Command
{
public override void Execute(CommandQueue commandQueue, Action onComplete)
{
Game game = Game.GetInstance();
game.cameraController.StopManualPan();
game.cameraController.StopSwipePan();
if (onComplete != null)
{

24
Assets/Fungus/Scripts/Game.cs

@ -54,9 +54,9 @@ namespace Fungus
public Texture2D fadeTexture;
/**
* Icon to display when manual pan mode is active.
* Icon to display when swipe pan mode is active.
*/
public Texture2D manualPanTexture;
public Texture2D swipePanTexture;
/**
* Icon to display when waiting for player input to continue
@ -119,7 +119,7 @@ namespace Fungus
public bool waiting;
[HideInInspector]
public bool manualPanActive;
public bool swipePanActive;
[HideInInspector]
public float fadeAlpha = 0f;
@ -189,16 +189,16 @@ namespace Fungus
void OnGUI()
{
if (manualPanActive)
if (swipePanActive)
{
// Draw the swipe-to-pan icon
if (manualPanTexture)
// Draw the swipe panning icon
if (swipePanTexture)
{
Rect rect = new Rect(Screen.width - manualPanTexture.width,
Screen.height - manualPanTexture.height,
manualPanTexture.width,
manualPanTexture.height);
GUI.DrawTexture(rect, manualPanTexture);
Rect rect = new Rect(Screen.width - swipePanTexture.width,
Screen.height - swipePanTexture.height,
swipePanTexture.width,
swipePanTexture.height);
GUI.DrawTexture(rect, swipePanTexture);
}
}
@ -209,7 +209,7 @@ namespace Fungus
if (continueTexture)
{
Rect rect = new Rect(Screen.width - continueTexture.width,
Screen.height - manualPanTexture.height,
Screen.height - swipePanTexture.height,
continueTexture.width,
continueTexture.height);
GUI.DrawTexture(rect, continueTexture);

16
Assets/Fungus/Scripts/GameController.cs

@ -142,28 +142,28 @@ namespace Fungus
}
/**
* Activates manual pan mode.
* Activates swipe panning mode.
* The camera first pans to the nearest point between the two views over a period of time.
* The player can pan around the rectangular area defined between viewA & viewB.
* Manual panning remains active until a ManualPanOff, SetView, PanToView, FadeToPath or FadeToView command is executed.
* The player can then pan around the rectangular area defined between viewA & viewB.
* Swipe panning remains active until a StopSwipePan, SetView, PanToView, FadeToPath or FadeToView command is executed.
* This method returns immediately but it queues an asynchronous command for later execution.
* @param viewA View object which defines one extreme of the pan area.
* @param viewB View object which defines the other extreme of the pan area.
*/
public static void StartManualPan(View viewA, View viewB, float duration = 1f)
public static void StartSwipePan(View viewA, View viewB, float duration = 1f)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.StartManualPan(viewA, viewB, duration));
commandQueue.AddCommand(new Command.StartSwipePan(viewA, viewB, duration));
}
/**
* Deactivates manual pan mode.
* Deactivates swipe panning mode.
* This method returns immediately but it queues an asynchronous command for later execution.
*/
public static void StopManualPan()
public static void StopSwipePan()
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.StopManualPan());
commandQueue.AddCommand(new Command.StopSwipePan());
}
/**

BIN
Assets/FungusExample/Scenes/Example.unity

Binary file not shown.

2
Assets/FungusExample/Scripts/MenuRoom.cs

@ -18,7 +18,7 @@ public class MenuRoom : Room
AddOption("Writing a story with Pages", MoveToWritingRoom);
AddOption("Controlling the camera with Views", MoveToViewRoom);
AddOption("Sprites and Animations", MoveToSpriteRoom);
AddOption("Manual pan and parallax", MoveToParallaxRoom);
AddOption("Swipe panning and parallax", MoveToParallaxRoom);
AddOption("Using Buttons", MoveToButtonsRoom);
AddOption("Playing music and sound effects", MoveToAudioRoom);
Choose("Choose an example");

4
Assets/FungusExample/Scripts/ParallaxRoom.cs

@ -19,7 +19,7 @@ public class ParallaxRoom : Room
{
SetView(viewA);
Say("Let's zoom in!");
Say("Let's move the camera!");
PanToView(viewB, 2);
Say("Oooh! Nice parallax!");
PanToView(viewA, 2);
@ -28,7 +28,7 @@ public class ParallaxRoom : Room
ShowButton(menuButton, OnHomeButtonClicked);
StartManualPan(viewA, viewB, 0f);
StartSwipePan(viewA, viewB, 0f);
}
void OnHomeButtonClicked()

Loading…
Cancel
Save