17 #ifndef HEADER_SUPERTUX_OBJECT_MOVING_SPRITE_HPP 18 #define HEADER_SUPERTUX_OBJECT_MOVING_SPRITE_HPP 20 #include "math/anchor_point.hpp" 21 #include "sprite/sprite.hpp" 22 #include "sprite/sprite_ptr.hpp" 23 #include "supertux/moving_object.hpp" 24 #include "video/drawing_context.hpp" 25 #include "video/flip.hpp" 36 static void register_class(ssq::VM& vm);
40 const std::string& sprite_name,
41 int layer = LAYER_OBJECTS,
42 CollisionGroup collision_group = COLGROUP_MOVING);
45 int layer = LAYER_OBJECTS,
46 CollisionGroup collision_group = COLGROUP_MOVING);
48 const std::string& sprite_name,
49 int layer = LAYER_OBJECTS,
50 CollisionGroup collision_group = COLGROUP_MOVING);
52 int layer = LAYER_OBJECTS,
53 CollisionGroup collision_group = COLGROUP_MOVING);
56 virtual void update(
float dt_sec)
override;
57 static std::string class_name() {
return "moving-sprite"; }
58 virtual std::string get_class_name()
const override {
return class_name(); }
59 virtual std::string get_exposed_class_name()
const override {
return "MovingSprite"; }
63 virtual void after_editor_set()
override;
66 virtual int get_layer()
const override {
return m_layer; }
68 bool has_found_sprite()
const {
return m_sprite_found; }
69 const std::string& get_sprite_name()
const {
return m_sprite_name; }
72 bool matches_sprite(
const std::string& sprite_file)
const;
73 bool change_sprite(
const std::string& new_sprite_name);
74 void spawn_explosion_sprites(
int count,
const std::string& sprite_path);
79 #ifdef DOXYGEN_SCRIPTING 85 void set_sprite(
const std::string& file);
114 void set_action(
const std::string& name,
int loops);
119 void set_action(
const std::string& name,
const Direction& dir,
int loops = -1);
124 void set_action(
const Direction& dir,
const std::string& name,
int loops = -1);
129 void set_action(
const Direction& dir,
int loops = -1);
139 void set_action(
const std::string& action,
int loops, AnchorPoint anchorPoint);
146 std::string m_sprite_name;
162 const bool m_custom_layer;
virtual void on_type_change(int old_type) override
Definition: moving_sprite.cpp:110
Definition: sprite.hpp:26
int m_layer
Sprite's z-position.
Definition: moving_sprite.hpp:153
void set_action_centered(const std::string &action, int loops=-1)
Set new action for sprite and re-center bounding box.
Definition: moving_sprite.cpp:181
std::string get_action() const
Returns the name of the current action of the sprite.
Definition: moving_sprite.cpp:127
Definition: object_settings.hpp:39
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it's state.
Definition: moving_sprite.cpp:105
virtual void update_hitbox()
Update hitbox, based on sprite.
Definition: moving_sprite.cpp:133
std::string m_default_sprite_name
The default sprite for this MovingObject.
Definition: moving_sprite.hpp:151
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
Sprite * get_sprite() const
Get various sprite properties.
Definition: moving_sprite.hpp:77
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: moving_sprite.cpp:99
void set_action(const std::string &name)
Sets the current action of the sprite and resizes the bounding box.
Definition: moving_sprite.cpp:140
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
void set_action_loops(const std::string &name, int loops)
Sets the current action of the sprite, as well as the number of times it should loop, and resizes the bounding box.
Definition: moving_sprite.cpp:147
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_object.hpp:49
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
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42