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