Sprites

We have already mentioned the concept of a sprite being an entity that is drawn and handled at a specific position on a screen. Essentially, everything we see in a game are sprites. There are exceptions, such as game controllers (which do not draw anything) and backgrounds (which are drawn in a different way), but we will talk about them later in the chapter.

So, this is the code for the Sprite class that extends GameObject:

public abstract class Sprite extends GameObject { protected double mPositionX; protected double mPositionY; protected final double mPixelFactor; private final Bitmap mBitmap; protected final int mImageHeight; protected final int mImageWidth; private final Matrix mMatrix = new Matrix(); protected Sprite (GameEngine gameEngine, ...

Get Android Game Programming: A Developer’s Guide 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.