• $19 Game Dev' Courses - Use code "FEBUDEMY"

    Video courses

The Complete Java Developer Course. Learn Step by Step

The Complete Android & Java Developer Course – Build 21 Apps

Master Android N App Development With Java

As the title of the tutorial suggests we will be using interfaces. Interfaces are a special type of class and we already know how to create classes. However, we will not be creating any of our own interfaces until we get to the level two tutorials. There is no need, we can still make some really cool games without doing so but we will use interfaces that have been created for us as they can bring complex functionality to our games with great ease.

An interface is a class which has no method implementations. This might sound a bit odd but one of the things this achieves is to provide us with the ability to override these methods in our code. This is especially helpful as these methods are called by the operating system at events that are useful to us.

We saw something similar in our thread tutorial. We overrode the run method by using the @override keyword. When we do this we can be sure that our code, enclosed in the run method, as well as any other methods we call from this method, (like update and draw)  will work in the thread.

Interfaces can also provide critical functionality like allowing us to interact with the user’s input. For example, for Android, all we need to do is use the onTouchListener interface and we can then @override the onTouchEvent method. Then, every time the player touches the screen we can deal with it, according to the needs of our game. Just like this.

public boolean onTouchEvent(MotionEvent motionEvent) {

	// Handle the player input here


Note that the method and interface names are different when dealing with desktop Java but the concept is identical.

  • Learning java by building Android games

    Learning Java by Building Android Games

    Want to learn Java for Android? Even if you are completely new to either Java, Android, or game programming but are aiming to publish Android games, then this book is for you. This book also acts as a refresher for those who already have experience in Java on other platforms or other object-oriented languages.
    • Setup your own Android game programming environment using Android Studio
    • Control logic, branch your code, and add real decision-making depth to your games
    • Design and use 2d sprite animations, smooth pixel graphics, sound FX, simple collision detection and artificial intelligence (AI)
    • Build around a dozen sample test apps and 4 complete working games!
    Amazon USA
    Amazon UK
    Amazon CA
    Our Store (US only)

    Android Game Programming by Example

    Learn to build exciting Android game projects. Build a simple flappy-bird like game to a multi-environment, tough, retro platformer then an OpenGL ES 2 Asteroids clone, running at hundreds of frames per second .
    • Animate your characters with sprite sheets, add multiple scrolling parallax backgrounds, and implement genuinely tough, playable levels in your games
    • Every single line of code is printed in the book! No need to refer to the code files while trying to follow along. All the code files are also supplied separately so you can refer to them in their completed form and copy/paste them into your project if you like.
    • Implement a multitude of other game features such as pickups, firing weapons, HUD’s, generating and playing sound FX, scenery, level transition, high scores, and more
    Amazon USA
    Amazon UK
    Amazon CA
    Our Store (US Only)

The final explanation that is necessary before we build a game is that in Java everything is a class or part of a class. Our game is no exception. You will have seen this already if you completed any of the mini projects associated with earlier tutorials. When we declare our class all we have to do is add the implements keyword followed by the name of the interface or interfaces we want to use.

Let’s put into action and clarify everything we have learned in the previous 10 tutorials and build a simple game engine.