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) :
29 using namespace worldmap;
31 floating_image = new _FloatingImage(spritefile);
32 if(Sector::current() != NULL) {
33 Sector::current()->add_object(floating_image.get());
34 } else if(WorldMap::current() != NULL) {
35 WorldMap::current()->add_object(floating_image.get());
37 throw new std::runtime_error("Neither sector nor worldmap active");
41 FloatingImage::~FloatingImage()
43 floating_image->remove_me();
47 FloatingImage::set_layer(int layer)
49 floating_image->set_layer(layer);
53 FloatingImage::get_layer()
55 return floating_image->get_layer();
59 FloatingImage::set_pos(float x, float y)
61 floating_image->set_pos(Vector(x, y));
65 FloatingImage::get_pos_x()
67 return floating_image->get_pos().x;
71 FloatingImage::get_pos_y()
73 return floating_image->get_pos().y;
77 FloatingImage::set_anchor_point(int anchor)
79 floating_image->set_anchor_point((AnchorPoint) anchor);
83 FloatingImage::get_anchor_point()
85 return (int) floating_image->get_anchor_point();
89 FloatingImage::get_visible()
91 return floating_image->get_visible();
95 FloatingImage::set_visible(bool visible)
97 floating_image->set_visible(visible);
101 FloatingImage::set_action(const std::string& action)
103 floating_image->set_action(action);
107 FloatingImage::get_action()
109 return floating_image->get_action();
113 FloatingImage::fade_in(float fadetime)
115 floating_image->fade_in(fadetime);
119 FloatingImage::fade_out(float fadetime)
121 floating_image->fade_out(fadetime);