Skip to main content

Alternative Sources of User Input

  • Chapter
  • First Online:
Java Game Development with LibGDX

Abstract

In previous chapters, your games have been controlled with traditional desktop computer hardware: a keyboard and a mouse. In this chapter, you’ll explore two alternative sources of user input: gamepad controllers and touchscreen controls. In particular, you will add these alternative sources of user input to the Starfish Collector game that has been featured in previous chapters. If you do not have access to a gamepad with a USB connector (as discussed later in this chapter), you can still follow along; the code will still compile, and you’ll leave keyboard controls as a fallback (a good practice to consider in general for the convenience of your game’s players). Similarly, even if you don’t have access to a device that’s touchscreen capable, learning about the associated design considerations is still worthwhile. Furthermore, touch events and mouse events are handled by the same methods in LibGDX; you can simulate single-touch input (but not multitouch input) with the mouse. On the other hand, if neither gamepad nor touch-based input is of interest to you, this entire chapter may be omitted without loss of continuity.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 79.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The control element typically referred to as a directional pad was referred to as a point-of-view control in traditional flight simulators, which explains the use of the POV acronym in the LibGDX source code.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Lee Stemkoski

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Stemkoski, L. (2018). Alternative Sources of User Input. In: Java Game Development with LibGDX. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3324-5_13

Download citation

Publish with us

Policies and ethics