The game is coming together nicely, and we can now turn our attention to the GameObject
class. Much will look familiar to the previous project. Create a class called GameObject
and add the following member variables.
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import com.gamecodeschool.platformer.GOSpec.GameObjectSpec;
class GameObject {
private Transform mTransform;
private boolean mActive = true;
private String mTag;
private GraphicsComponent mGraphicsComponent;
private UpdateComponent mUpdateComponent;
}
The members are almost the same as the previous project except we have an instance of an UpdateComponent
replacing an instance of a MovementComponent
.
Next add the following methods which are used to initialize the component-based and Transform
instances that we just...