Coding the basic transform

In this project we will do a better job of the Transform class. In the Scrolling Shooter project, the Transform was packed full of variables and methods that many of the objects didn't need. It served its purpose to prevent the project getting even bigger and we got away with it because there was a limited number of objects in the game.

What we will code now is a very simple version of the Transform and it will contain only the members and methods needed by all game objects. When we need a Transform that does more specific things we can then extend this class and add the required extra members and methods.

Add a new class called Transform. Code the member variables and the constructor as shown next.

import android.graphics.PointF; ...

Get Learning Java by Building Android Games - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.