supertux
sprite_change.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
18 #define HEADER_SUPERTUX_WORLDMAP_SPRITE_CHANGE_HPP
19 
20 #include <list>
21 #include <string>
22 
23 #include "math/vector.hpp"
24 #include "sprite/sprite_ptr.hpp"
25 #include "supertux/game_object.hpp"
26 
27 class ReaderMapping;
28 class Sprite;
29 
30 namespace worldmap {
31 
32 class SpriteChange final : public GameObject
33 {
34 private:
35  static std::list<SpriteChange*> s_all_sprite_changes;
36 
37 public:
38  SpriteChange(const ReaderMapping& mapping);
39  virtual ~SpriteChange();
40 
41  virtual void draw(DrawingContext& context) override;
42  virtual void update(float dt_sec) override;
43 
47  void set_stay_action();
48 
53  void clear_stay_action(bool propagate = true);
54 
55  /*
56  * Get the current value of in_stay_action
57  */
58  bool show_stay_action() const;
59 
60  Vector get_pos() const { return m_pos; }
61 
62 private:
63  Vector m_pos;
64 
65 public:
69 
71  SpritePtr m_sprite;
72  std::string m_sprite_name;
73 
74 private:
78  std::string m_stay_action;
79 
82  std::string m_stay_group;
83 
84 private:
86  bool m_in_stay_action;
87 
88 private:
89  SpriteChange(const SpriteChange&) = delete;
90  SpriteChange& operator=(const SpriteChange&) = delete;
91 };
92 
93 } // namespace worldmap
94 
95 #endif
96 
97 /* EOF */
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: sprite.hpp:25
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: sprite_change.cpp:58
void clear_stay_action(bool propagate=true)
Deactivates the SpriteChange&#39;s stay action, if applicable.
Definition: sprite_change.cpp:84
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: sprite_change.cpp:67
bool m_change_on_touch
should tuxs sprite change when the tile has been completely entered, or already when the tile was jus...
Definition: sprite_change.hpp:68
Definition: object_settings.hpp:28
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
Definition: sprite_change.hpp:32
void set_stay_action()
Activates the SpriteChange&#39;s stay action, if applicable.
Definition: sprite_change.cpp:78
Definition: reader_mapping.hpp:31
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
SpritePtr m_sprite
sprite to change tux image to
Definition: sprite_change.hpp:71