00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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