YAPOG  0.0.1
Yet Another Pokemon Online Game
Sprite.cpp
Go to the documentation of this file.
2 
3 namespace yap
4 {
6  : BaseSprite ()
7  , texture_ (nullptr)
8  {
9  }
10 
12  : BaseSprite ()
13  , texture_ (texture)
14  {
15  }
16 
17  Sprite::Sprite (const String& textureName)
18  : BaseSprite ()
19  , texture_ (new Texture (textureName))
20  {
21  }
22 
23  Sprite::Sprite (const String& textureName, const sf::IntRect& textureRect)
24  : BaseSprite ()
25  , texture_ (new Texture (textureName, textureRect))
26  {
27  }
28 
30  {
31  delete texture_;
32  texture_ = nullptr;
33  }
34 
35  void Sprite::SetTexture (Texture* texture)
36  {
37  texture_ = texture;
38  }
39 
41  {
42  return new Sprite (*this);
43  }
44 
45  Sprite::Sprite (const Sprite& copy)
46  : BaseSprite (copy)
47  , texture_ (copy.texture_->Clone ())
48  {
49  }
50 
52  {
53  return texture_->GetSize ();
54  }
55 
56  void Sprite::HandleMove (const Vector2& offset)
57  {
58  texture_->Move (offset);
59  }
60 
61  void Sprite::HandleScale (const Vector2& factor)
62  {
63  texture_->Scale (factor);
64  }
65 
67  {
68  texture_->Draw (context);
69  }
70 
71  void Sprite::HandleShow (bool isVisible)
72  {
73  }
74 
75  void Sprite::HandleChangeColor (const sf::Color& color)
76  {
77  texture_->ChangeColor (color);
78  }
79 
80  void Sprite::HandleUpdate (const Time& dt)
81  {
82  }
83 } // namespace yap