Game Development Reference
In-Depth Information
First add the following method to Ship and Bullet :
std::shared_ptr<Sprite> GetSprite() { return
_sprite; }
Adjust as necessary to fit your sprite name. We need this to retrieve and re-add the
sprites when the game is restarted.
Inside Renderer we need to add a couple of methods to extend our Sprite and
TextBlock management.
void Renderer::ClearSprites()
{
_sprites.clear();
}
void
Renderer::AddSprite(std::shared_ptr<Sprite>
sprite)
{
_sprites.push_back(sprite);
}
void Renderer::ClearText()
{
_text.clear();
}
void Renderer::AddText(TextBlock *text)
{
_text.push_back(text);
}
Here we just need a way to mass clear all of the Sprites and TextBlocks, as well
as a way to add them without creating new ones. This way we can re-add the play-
er/enemy/bullet sprites during a game restart without destroying and recreating the
Sprite objects. Once we have that in place we need to add two methods to our
Search WWH ::




Custom Search