supertux
floating_image.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_OBJECT_FLOATING_IMAGE_HPP
18 #define HEADER_SUPERTUX_OBJECT_FLOATING_IMAGE_HPP
19 
20 #include "math/anchor_point.hpp"
21 #include "sprite/sprite_ptr.hpp"
22 #include "supertux/game_object.hpp"
23 
32 class FloatingImage final : public GameObject
33 {
34 public:
35  static void register_class(ssq::VM& vm);
36 
37 public:
38  FloatingImage(const std::string& sprite);
39  ~FloatingImage() override;
40 
41  virtual bool is_saveable() const override { return false; }
42  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(FloatingImage)); }
43  virtual std::string get_exposed_class_name() const override { return "FloatingImage"; }
44 
45  virtual void update(float dt_sec) override;
46  virtual void draw(DrawingContext& context) override;
47 
54  void set_layer(int layer);
60  int get_layer() const;
67  void set_pos(float x, float y);
72  float get_x() const;
77  float get_y() const;
78 #ifdef DOXYGEN_SCRIPTING
79 
84  float get_pos_x() const;
90  float get_pos_y() const;
91 #endif
92 
97  void set_anchor_point(int anchor);
102  int get_anchor_point() const;
109  void set_visible(bool visible);
115  bool get_visible() const;
122  void set_action(const std::string& action);
128  std::string get_action() const;
134  void fade_in(float time);
140  void fade_out(float time);
141 
142 private:
143  SpritePtr m_sprite;
148  int m_layer;
153  bool m_visible;
154  AnchorPoint m_anchor;
155  Vector m_pos;
156  float m_fading;
157  float m_fadetime;
158 };
159 
160 #endif
161 
162 /* EOF */
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: floating_image.cpp:43
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: floating_image.cpp:146
void set_pos(float x, float y)
Sets the location of the image in relation to the current anchor point.
Definition: floating_image.cpp:78
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: floating_image.hpp:41
float get_y() const
Returns the image&#39;s Y coordinate relative to the current anchor point.
Definition: floating_image.cpp:90
void set_layer(int layer)
Definition: floating_image.cpp:66
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: floating_image.hpp:42
void set_anchor_point(int anchor)
Sets the image&#39;s anchor point.
Definition: floating_image.cpp:96
void fade_out(float time)
Fades out the image for the next ""time"" seconds.
Definition: floating_image.cpp:139
This class provides the ability to create, edit, and remove images floating in midair on the screen...
Definition: floating_image.hpp:32
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
bool get_visible() const
Definition: floating_image.cpp:108
void fade_in(float time)
Fades in the image for the next ""time"" seconds.
Definition: floating_image.cpp:132
void set_action(const std::string &action)
Sets the action of the image.
Definition: floating_image.cpp:120
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
int get_layer() const
Definition: floating_image.cpp:72
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
int get_anchor_point() const
Returns the current anchor point.
Definition: floating_image.cpp:102
float get_x() const
Returns the image&#39;s X coordinate relative to the current anchor point.
Definition: floating_image.cpp:84
std::string get_action() const
Returns the name of the action of the image, as defined in the sprite.
Definition: floating_image.cpp:126
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
void set_visible(bool visible)
Definition: floating_image.cpp:114