17 #ifndef HEADER_SUPERTUX_OBJECT_BACKGROUND_HPP 18 #define HEADER_SUPERTUX_OBJECT_BACKGROUND_HPP 20 #include "math/vector.hpp" 21 #include "sprite/sprite_ptr.hpp" 22 #include "supertux/game_object.hpp" 23 #include "supertux/timer.hpp" 24 #include "video/blend.hpp" 25 #include "video/drawing_context.hpp" 26 #include "video/flip.hpp" 38 static void register_class(ssq::VM& vm);
45 virtual void update(
float dt_sec)
override;
48 static std::string class_name() {
return "background"; }
49 virtual std::string get_class_name()
const override {
return class_name(); }
50 virtual std::string get_exposed_class_name()
const override {
return "Background"; }
51 static std::string display_name() {
return _(
"Background"); }
55 virtual const std::string get_icon_path()
const override {
56 return "images/engine/editor/background.png";
60 virtual void after_editor_set()
override;
62 virtual void on_flip(
float height)
override;
66 const std::string& get_image()
const {
return m_imagefile; }
67 float get_speed()
const {
return m_parallax_speed.x; }
68 int get_layer()
const {
return m_layer; }
70 Color get_color()
const {
return m_color; }
71 void fade_color(
Color color,
float time);
86 void set_images(
const std::string& top_image,
const std::string& middle_image,
87 const std::string& bottom_image);
123 void set_color(
float red,
float green,
float blue,
float alpha);
133 void fade_color(
float red,
float green,
float blue,
float alpha,
float time);
168 Alignment m_alignment;
176 std::string m_imagefile_top;
177 std::string m_imagefile;
178 std::string m_imagefile_bottom;
180 Vector m_parallax_speed;
181 Vector m_scroll_speed;
182 Vector m_scroll_offset;
183 SpritePtr m_image_top;
185 SpritePtr m_image_bottom;
189 DrawingTarget m_target;
192 Color m_src_color, m_dst_color;
void set_image_action(const std::string &action)
Sets the sprite action for the main (middle) image.
Definition: background.cpp:558
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: background.cpp:520
void set_bottom_image_action(const std::string &action)
Sets the sprite action for the bottom image.
Definition: background.cpp:564
float get_color_red() const
Returns the red color value.
Definition: background.cpp:392
void set_image(const std::string &image)
Sets the background's image.
Definition: background.cpp:363
void set_images(const std::string &top_image, const std::string &middle_image, const std::string &bottom_image)
Sets the top, middle and bottom background images.
Definition: background.cpp:370
void set_all_image_actions(const std::string &action)
Sets the sprite action for all images (top, middle and bottom).
Definition: background.cpp:571
float get_color_blue() const
Returns the blue color value.
Definition: background.cpp:404
A ""Background"" that was given a name can be manipulated by scripts.
Definition: background.hpp:35
Definition: object_settings.hpp:39
float get_color_green() const
Returns the green color value.
Definition: background.cpp:398
void set_speed(float speed)
Sets the background speed.
Definition: background.cpp:385
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: background.cpp:322
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: background.cpp:579
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: background.hpp:53
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
float get_color_alpha() const
Returns the alpha color value.
Definition: background.cpp:410
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
void set_top_image_action(const std::string &action)
Sets the sprite action for the top image.
Definition: background.cpp:551
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
void set_color(float red, float green, float blue, float alpha)
Sets the background color.
Definition: background.cpp:340
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user's locale.
Definition: background.hpp:52
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42