O'Reilly logo

LibGDX Game Development Essentials by Juwal Bose

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Interacting with 3D objects

Let's discuss how to select 3D objects present in a scene. We will add 10 planes to the scene, store them in an array named instances, and select any of them by tapping. The selected plane will be set to rotate until another selection is made. We will add an InputAdapter class's instance named myAdapter and wire it to accept inputs via an InputMultiplexer interface, as we also need our cameraController instance to receive inputs. The code is as follows:

InputAdapter myAdapter=new InputAdapter(){ @Override public boolean touchDown (int screenX, int screenY, int pointer, int button) { selecting = getObject(screenX, screenY); return selecting >= 0; } @Override public boolean touchDragged (int screenX, int screenY, int pointer) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required