src/trigger/sequence_trigger.cpp

Go to the documentation of this file.
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 "object/player.hpp"
00018 #include "supertux/object_factory.hpp"
00019 #include "trigger/sequence_trigger.hpp"
00020 #include "util/reader.hpp"
00021 
00022 SequenceTrigger::SequenceTrigger(const Reader& reader) :
00023   triggerevent(),
00024   sequence_name()
00025 {
00026   reader.get("x", bbox.p1.x);
00027   reader.get("y", bbox.p1.y);
00028   float w = 0, h = 0;
00029   reader.get("width", w);
00030   reader.get("height", h);
00031   bbox.set_size(w, h);
00032   reader.get("sequence", sequence_name);
00033   triggerevent = EVENT_TOUCH;
00034 }
00035 
00036 SequenceTrigger::SequenceTrigger(const Vector& pos, const std::string& sequence) :
00037   triggerevent(),
00038   sequence_name()
00039 {
00040   bbox.set_pos(pos);
00041   bbox.set_size(32, 32);
00042   sequence_name = sequence;
00043   triggerevent = EVENT_TOUCH;
00044 }
00045 
00046 SequenceTrigger::~SequenceTrigger()
00047 {
00048 }
00049 
00050 void
00051 SequenceTrigger::event(Player& player, EventType type)
00052 {
00053   if(type == triggerevent) {
00054     player.trigger_sequence(sequence_name);
00055   }
00056 }
00057 
00058 /* EOF */

Generated on Mon Jun 9 03:38:23 2014 for SuperTux by  doxygen 1.5.1