Book Image

Mastering LibGDX Game Development

By : Patrick Hoey
Book Image

Mastering LibGDX Game Development

By: Patrick Hoey

Overview of this book

Table of Contents (18 chapters)
Mastering LibGDX Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Camera shake


The next effect deals with making the blows dealt and received in the game more impactful. Sound effects definitely help, but some visual cues also can really add to this effect. The ShakeCamera class will generate random coordinates based on a starting position. At the beginning of a shake cycle, these positional changes will be significant, but over time, these positional changes will get smaller until we reach some defined threshold. These positional changes give the illusion that the target is shaking on the screen.

The following class diagram (Figure 2) shows where the ShakeCamera class is primarily used:

Figure 2

In BludBourne, the ShakeCamera class is used in two areas. The first area in which the ShakeCamera class is used is in the PlayerHUD class, when the player has sustained damage from an enemy during battle. The UI will shake for a specified amount of time, signaling to the player that they have been hit. The second area in which the ShakeCamera class is used is in...