
134 5. Sprites and Animation
planet.setX(GAME_WIDTH*0.5f - planet.getWidth()*0.5f);
planet.setY(GAME_HEIGHT*0.5f - planet.getHeight()*0.5f);
return;
}
Listing 5.28. Initializing the nebula and planet.
e Spacewar::render function calls graphics->spriteBegin() to begin draw-
ing sprites. en it calls nebula.draw() and planet.draw() functions to add the neb-
ula and planet to the scene. Sprite drawing is ended by calling graphics->spriteEnd()
(Listing 5.29).
e order of drawing is important. We want the planet to appear in front of the nebula so we
draw the nebula rst and then draw the planet.
We override the releaseAll and resetAll functions ...