Book Image

Libgdx Cross-platform Game Development Cookbook

Book Image

Libgdx Cross-platform Game Development Cookbook

Overview of this book

Table of Contents (20 chapters)
Libgdx Cross-platform Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Understanding orthographic cameras


Very much like in films, Libgdx uses the concept of a camera as a tool to visualize the world. Throughout this recipe, we will learn how to wield the features of orthographic cameras, which make 2D scene rendering a much more enjoyable endeavor.

Among the topics shown, we can highlight camera sizes, movement, and zooming. This time around, in our example, we will load a massive texture and allow the user to move around, zooming in and out with both keyboard and touch controls. Naturally, in a real-life situation, you would have a level made out of chunks rather than a big texture.

Getting ready

Just make sure you already have the sample projects in your Eclipse workspace.

How to do it…

To start working with orthographic cameras, please open the OrthographicCameraSample.java file, which contains an implementation of our familiar friend, the ApplicationListener interface.

First of all, we define constants for the camera movement speed, area of the screen that will...