00001 // SuperTux 00002 // Copyright (C) 2006 Matthias Braun <matze@braunis.de> 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #include <stdexcept> 00018 00019 #include "object/floating_image.hpp" 00020 #include "scripting/floating_image.hpp" 00021 #include "supertux/sector.hpp" 00022 #include "worldmap/worldmap.hpp" 00023 00024 namespace scripting { 00025 00026 FloatingImage::FloatingImage(const std::string& spritefile) : 00027 floating_image() 00028 { 00029 using namespace worldmap; 00030 00031 floating_image = new _FloatingImage(spritefile); 00032 if(Sector::current() != NULL) { 00033 Sector::current()->add_object(floating_image.get()); 00034 } else if(WorldMap::current() != NULL) { 00035 WorldMap::current()->add_object(floating_image.get()); 00036 } else { 00037 throw new std::runtime_error("Neither sector nor worldmap active"); 00038 } 00039 } 00040 00041 FloatingImage::~FloatingImage() 00042 { 00043 floating_image->remove_me(); 00044 } 00045 00046 void 00047 FloatingImage::set_layer(int layer) 00048 { 00049 floating_image->set_layer(layer); 00050 } 00051 00052 int 00053 FloatingImage::get_layer() 00054 { 00055 return floating_image->get_layer(); 00056 } 00057 00058 void 00059 FloatingImage::set_pos(float x, float y) 00060 { 00061 floating_image->set_pos(Vector(x, y)); 00062 } 00063 00064 float 00065 FloatingImage::get_pos_x() 00066 { 00067 return floating_image->get_pos().x; 00068 } 00069 00070 float 00071 FloatingImage::get_pos_y() 00072 { 00073 return floating_image->get_pos().y; 00074 } 00075 00076 void 00077 FloatingImage::set_anchor_point(int anchor) 00078 { 00079 floating_image->set_anchor_point((AnchorPoint) anchor); 00080 } 00081 00082 int 00083 FloatingImage::get_anchor_point() 00084 { 00085 return (int) floating_image->get_anchor_point(); 00086 } 00087 00088 bool 00089 FloatingImage::get_visible() 00090 { 00091 return floating_image->get_visible(); 00092 } 00093 00094 void 00095 FloatingImage::set_visible(bool visible) 00096 { 00097 floating_image->set_visible(visible); 00098 } 00099 00100 void 00101 FloatingImage::set_action(const std::string& action) 00102 { 00103 floating_image->set_action(action); 00104 } 00105 00106 std::string 00107 FloatingImage::get_action() 00108 { 00109 return floating_image->get_action(); 00110 } 00111 00112 void 00113 FloatingImage::fade_in(float fadetime) 00114 { 00115 floating_image->fade_in(fadetime); 00116 } 00117 00118 void 00119 FloatingImage::fade_out(float fadetime) 00120 { 00121 floating_image->fade_out(fadetime); 00122 } 00123 00124 } 00125 00126 /* EOF */