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; import android.graphics.RectF; public class Transform { RectF mCollider; private PointF mLocation; private float mSpeed; private float mObjectHeight; private float mObjectWidth; private PointF mStartingPosition...