1 | #include "mouseapiexample.h" |
---|
2 | #include "gametypes/Gametype.h" |
---|
3 | #include "infos/PlayerInfo.h" |
---|
4 | #include "worldentities/CameraPosition.h" |
---|
5 | #include "worldentities/ControllableEntity.h" |
---|
6 | |
---|
7 | namespace orxonox |
---|
8 | { |
---|
9 | |
---|
10 | RegisterClass(MouseAPIExample); |
---|
11 | |
---|
12 | MouseAPIExample::MouseAPIExample(Context* context) : ControllableEntity(context) |
---|
13 | { |
---|
14 | RegisterObject(MouseAPIExample); |
---|
15 | } |
---|
16 | |
---|
17 | MouseAPIExample::~MouseAPIExample() |
---|
18 | { |
---|
19 | if(MouseAPI::isActive()) |
---|
20 | MouseAPI::getInstance().deactivate(); |
---|
21 | |
---|
22 | } |
---|
23 | |
---|
24 | void MouseAPIExample::testfunction(MouseButtonCode::ByEnum mouse) |
---|
25 | { |
---|
26 | float randomnumber = (rand()%100 + 1)/20.0; |
---|
27 | this->setScale(randomnumber); |
---|
28 | orxout() << "Blah\n"; |
---|
29 | //this->getGametype()->getPlayers().begin()->first->getControllableEntity()->mouseLook();//getCurrentCameraPosition()->setAllowMouseLook(false); |
---|
30 | //this->getGametype()->getPlayers().begin()->first->stopControl(); |
---|
31 | |
---|
32 | } |
---|
33 | |
---|
34 | void MouseAPIExample::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
35 | { |
---|
36 | SUPER(MouseAPIExample, XMLPort, xmlelement, mode); |
---|
37 | MouseAPI::getInstance().activate(); |
---|
38 | MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->testfunction(mouse);}); |
---|
39 | //this->getGametype()->getPlayers().begin()->first->getControllableEntity()->mouseLook(); |
---|
40 | |
---|
41 | |
---|
42 | } |
---|
43 | } |
---|