2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
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.
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.
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/>.
19 #include "object/floating_image.hpp"
20 #include "scripting/floating_image.hpp"
21 #include "supertux/sector.hpp"
22 #include "worldmap/worldmap.hpp"
26 FloatingImage::FloatingImage(const std::string& spritefile) :
27 floating_image(std::make_shared<_FloatingImage>(spritefile))
29 using namespace worldmap;
31 if(Sector::current() != NULL) {
32 Sector::current()->add_object(floating_image);
33 } else if(WorldMap::current() != NULL) {
34 WorldMap::current()->add_object(floating_image);
36 throw new std::runtime_error("Neither sector nor worldmap active");
40 FloatingImage::~FloatingImage()
42 floating_image->remove_me();
46 FloatingImage::set_layer(int layer)
48 floating_image->set_layer(layer);
52 FloatingImage::get_layer()
54 return floating_image->get_layer();
58 FloatingImage::set_pos(float x, float y)
60 floating_image->set_pos(Vector(x, y));
64 FloatingImage::get_pos_x()
66 return floating_image->get_pos().x;
70 FloatingImage::get_pos_y()
72 return floating_image->get_pos().y;
76 FloatingImage::set_anchor_point(int anchor)
78 floating_image->set_anchor_point((AnchorPoint) anchor);
82 FloatingImage::get_anchor_point()
84 return (int) floating_image->get_anchor_point();
88 FloatingImage::get_visible()
90 return floating_image->get_visible();
94 FloatingImage::set_visible(bool visible)
96 floating_image->set_visible(visible);
100 FloatingImage::set_action(const std::string& action)
102 floating_image->set_action(action);
106 FloatingImage::get_action()
108 return floating_image->get_action();
112 FloatingImage::fade_in(float fadetime)
114 floating_image->fade_in(fadetime);
118 FloatingImage::fade_out(float fadetime)
120 floating_image->fade_out(fadetime);