O'Reilly logo

LibGDX Cross-Platform Development Blueprints by Indraneel Potnis

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

Taking input

We are now going to see how to capture the touch/click input and open a door when it has been touched.

Updating the GameManager class

We have to make changes to the structure of our GameManager class. The changed/added lines are highlighted in the following code:

package com.packtpub.managers;

import com.packtpub.gameobjects.Door;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;

public class GameManager {
    static Array<Door> doors ; // array of the 3 doors
    static Texture doorTexture; // texture image for the door
 static Texture carTexture; // texture ...

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