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

Implementing input handling for player character movement


Our final class that we need to implement for this chapter is PlayerController. PlayerController is responsible for handling all of the input events and providing mechanisms to process these events in the queue. This class can be found at core/src/com/packtpub/libgdx/bludbourne/PlayerController.java.

PlayerController

A class diagram of this class is shown in the following screenshot (Figure 14):

Figure 14

The source for PlayerController is listed here:

package com.packtpub.libgdx.bludbourne;

import java.util.HashMap;
import java.util.Map;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.math.Vector3;

InputProcessor is an interface that you should implement in order to process input events such as mouse cursor location changes, mouse button presses, and keyboard key presses from the input event handler. Your game will usually instantiate this class and set it in...