O'Reilly logo

Mastering Android Game Development by Raul Portales

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required