9.5. The cSpriteIcon class

The author did a lot of coding and encapsulating in order to come up with a cSprite child class called cSpriteIcon. cSpriteIcon has a constructor cSpriteIcon(int resourceID) which takes the ID of a bitmap resource as its argument. To make things nicer, the cSpriteIcon will automatically make the background of the image transparent. To give a critter a transparent-background sprite based on a resource bitmap with an ID like, say, IDB_EARTH, we only need to add a single line to the critter’s constructor.

setSprite(new cSpriteIcon(IDB_EARTH)); 

We also have the option of not having a transparent background at all. The full prototype of the cSpriteIcon constructor looks like this.

 cSpriteIcon(int resourceID, BOOL transparent ...

Get Software Engineering and Computer Games 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.