Every object is a GameObject
This class will become a living-breathing (or flying-shooting or diving etc) combination of our various components.
Create the GameObject
class and add the import
statements and constructor shown next.
import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PointF; class GameObject { private Transform mTransform; private boolean isActive = false; private String mTag; private GraphicsComponent graphicsComponent; private MovementComponent movementComponent; private SpawnComponent spawnComponent; }
We can see in the previous code that we have an instance of the Transform
class called mTransform
. In addition, we have a boolean
called isActive
which will act as an indicator whether the object is currently in use or not. The mTag
variable will be the same value as the tag from the specification classes we coded back in the section Coding all the specific object specifications.
The...