- Timestamp:
- Apr 11, 2019, 4:52:57 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc
r12296 r12302 19 19 if(MouseAPI::isActive()) 20 20 MouseAPI::getInstance().deactivate(); 21 22 21 } 23 22 24 void MouseAPIExample::testfunction(MouseButtonCode::ByEnum mouse) 23 // change the size of the cube to a random number by clicking on it 24 void MouseAPIExample::changesizeonclick(MouseButtonCode::ByEnum mouse) 25 25 { 26 float randomnumber = (rand()%100 + 1)/20.0; 26 // generate random number between 1 and 20 27 float randomnumber = std::fmax((rand()%100 + 1)/20.0,1); 28 // change the scale of the cube to this random number 27 29 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(); 30 // change the radius of the clickableObject to the new size 31 MouseAPI::getInstance().changeRadiusOfClickableObject(cubeid,randomnumber); 32 } 31 33 34 // change the size of the sphere by scrolling on it 35 void MouseAPIExample::changesizeonscroll(int abs,int rel,const IntVector2& mousePos) 36 { 37 // increase or decrease the size of the sphere 38 this->setScale(1+rel); 32 39 } 33 40 … … 35 42 { 36 43 SUPER(MouseAPIExample, XMLPort, xmlelement, mode); 44 //todo: id xml-port 37 45 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 46 cubeid = MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left},[this](MouseButtonCode::ByEnum mouse){this->changesizeonclick(mouse);}); 47 //sphereid = MouseAPI::addScrollElement(this->getWorldPosition(), 10, [this](int abs, int rel, const IntVector2& mousePos){this->changesizeonscroll(abs,rel,mousePos);}); 41 48 42 49 }
Note: See TracChangeset
for help on using the changeset viewer.