Last change
on this file since 12287 was
12287,
checked in by tkuonen, 6 years ago
|
MouseAPI: improve getting mouse pos
|
File size:
995 bytes
|
Rev | Line | |
---|
[12255] | 1 | #include "mouseapiexample.h" |
---|
[12287] | 2 | #include "gametypes/Gametype.h" |
---|
[12255] | 3 | |
---|
| 4 | namespace orxonox |
---|
| 5 | { |
---|
| 6 | |
---|
| 7 | RegisterClass(MouseAPIExample); |
---|
| 8 | |
---|
[12271] | 9 | MouseAPIExample::MouseAPIExample(Context* context) : ControllableEntity(context) |
---|
[12255] | 10 | { |
---|
| 11 | RegisterObject(MouseAPIExample); |
---|
[12287] | 12 | //this->getGametype()->getPlayers().begin()->first->getControllableEntity()... |
---|
[12255] | 13 | |
---|
[12287] | 14 | |
---|
[12255] | 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 | { |
---|
[12285] | 26 | float randomnumber = (rand()%100 + 1)/100.0; |
---|
| 27 | this->setScale(randomnumber); |
---|
| 28 | orxout() << "Blah\n"; |
---|
[12271] | 29 | |
---|
| 30 | } |
---|
| 31 | |
---|
[12255] | 32 | void MouseAPIExample::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 33 | { |
---|
| 34 | SUPER(MouseAPIExample, XMLPort, xmlelement, mode); |
---|
[12271] | 35 | MouseAPI::getInstance().activate(); |
---|
| 36 | MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->testfunction(mouse);}); |
---|
[12255] | 37 | } |
---|
| 38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.