floating_image.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #ifndef HEADER_SUPERTUX_OBJECT_FLOATING_IMAGE_HPP
  17. #define HEADER_SUPERTUX_OBJECT_FLOATING_IMAGE_HPP
  18. #include "math/anchor_point.hpp"
  19. #include "sprite/sprite_ptr.hpp"
  20. #include "supertux/game_object.hpp"
  21. class FloatingImage final : public GameObject
  22. {
  23. public:
  24. FloatingImage(const std::string& sprite);
  25. ~FloatingImage() override;
  26. virtual bool is_saveable() const override {
  27. return false;
  28. }
  29. void set_layer(int layer_) {
  30. layer = layer_;
  31. }
  32. int get_layer() const {
  33. return layer;
  34. }
  35. void set_pos(const Vector& pos_) {
  36. pos = pos_;
  37. }
  38. const Vector& get_pos() const {
  39. return pos;
  40. }
  41. void set_anchor_point(AnchorPoint anchor_) {
  42. anchor = anchor_;
  43. }
  44. AnchorPoint get_anchor_point() const {
  45. return anchor;
  46. }
  47. void set_visible(bool visible_) {
  48. visible = visible_;
  49. }
  50. bool get_visible() const {
  51. return visible;
  52. }
  53. void set_action(const std::string& action);
  54. std::string get_action();
  55. void fade_in(float fadetime);
  56. void fade_out(float fadetime);
  57. virtual void update(float dt_sec) override;
  58. virtual void draw(DrawingContext& context) override;
  59. private:
  60. SpritePtr sprite;
  61. int layer;
  62. bool visible;
  63. AnchorPoint anchor;
  64. Vector pos;
  65. float fading;
  66. float fadetime;
  67. };
  68. #endif
  69. /* EOF */