Skip to main content

Drag-and-Drop Games

  • Chapter
  • First Online:
Java Game Development with LibGDX
  • 1965 Accesses

Abstract

In this chapter, you will learn how to add drag-and-drop functionality to your games: the ability to click on an object and, while the mouse button is held down, have the selected object move along with the mouse until the button is released. Since this functionality is useful in many contexts, you will create an extension of the BaseActor class, called DragAndDropActor, containing the related code. To demonstrate the flexibility of this new class, you will create two new games that make use of this class. The first will be a jigsaw-puzzle game, shown in Figure 9-1, which consists of an image that has been broken into pieces and must be rearranged correctly on a grid. The second will be a solitaire card game called 52 Card Pickup, shown in Figure 9-2, where a standard deck of playing cards must be correctly arranged in a set of piles.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 59.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

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). Drag-and-Drop Games. In: Java Game Development with LibGDX. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3324-5_9

Download citation

Publish with us

Policies and ethics