Skip to content

Commit

Permalink
Added ShakeCamera() command.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgregan committed Jun 26, 2014
1 parent da31474 commit a266953
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Assets/Fungus/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,20 @@ public static void PanToStoredView(float duration, string viewName = "")
commandQueue.AddCommand(new Command.PanToStoredView(viewName, duration));
}

/**
* Applies a random shake to the camera.
* @param x Horizontal shake amount in world units.
* @param x Vertical shake amount in world units.
* @param duration Length of time for shake effect to last.
*/
public static void ShakeCamera(float x, float y, float duration)
{
CommandQueue commandQueue = Game.GetInstance().commandQueue;
commandQueue.AddCommand(new Command.Call(delegate {
iTween.ShakePosition(Camera.main.gameObject, new Vector3(x, y, 0), duration);
}));
}

#endregion
#region Dialog Methods

Expand Down
3 changes: 3 additions & 0 deletions Assets/FungusExample/Scripts/DialogRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void GoToSleep()
void ProduceSpores()
{
Say("Yeah! I feel like doing some sporing!");

ShakeCamera(0.1f, 0.1f, 0.2f);

Say("Wow - look at all these spores! COOL!");

// Sets a global value flag which we check above in GoToSleep
Expand Down

0 comments on commit a266953

Please sign in to comment.