Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc @ 12301

Last change on this file since 12301 was 12296, checked in by tkuonen, 6 years ago

added MouseGametype

File size: 1.3 KB
Line 
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
7namespace orxonox
8{
9
10RegisterClass(MouseAPIExample);
11
12MouseAPIExample::MouseAPIExample(Context* context) : ControllableEntity(context)
13{
14    RegisterObject(MouseAPIExample);
15}
16
17MouseAPIExample::~MouseAPIExample()
18{
19    if(MouseAPI::isActive())
20        MouseAPI::getInstance().deactivate();
21
22}
23
24void 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
34void 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}
Note: See TracBrowser for help on using the repository browser.