Line | |
---|
1 | #include "mouseapiexample.h" |
---|
2 | |
---|
3 | namespace orxonox |
---|
4 | { |
---|
5 | |
---|
6 | RegisterClass(MouseAPIExample); |
---|
7 | |
---|
8 | MouseAPIExample::MouseAPIExample(Context* context) : ControllableEntity(context) |
---|
9 | { |
---|
10 | RegisterObject(MouseAPIExample); |
---|
11 | |
---|
12 | } |
---|
13 | |
---|
14 | MouseAPIExample::~MouseAPIExample() |
---|
15 | { |
---|
16 | if(MouseAPI::isActive()) |
---|
17 | MouseAPI::getInstance().deactivate(); |
---|
18 | } |
---|
19 | |
---|
20 | void MouseAPIExample::testfunction(MouseButtonCode::ByEnum mouse) |
---|
21 | { |
---|
22 | float randomnumber = (rand()%100 + 1)/100.0; |
---|
23 | this->setScale(randomnumber); |
---|
24 | orxout() << "Blah\n"; |
---|
25 | |
---|
26 | } |
---|
27 | |
---|
28 | void MouseAPIExample::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
29 | { |
---|
30 | SUPER(MouseAPIExample, XMLPort, xmlelement, mode); |
---|
31 | MouseAPI::getInstance().activate(); |
---|
32 | MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->testfunction(mouse);}); |
---|
33 | } |
---|
34 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.