Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2019, 1:47:32 PM (6 years ago)
Author:
mkarpf
Message:

Test level finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapiexample.cc

    r12311 r12330  
    4242}
    4343
    44 //
     44// scale the z-component up / down with left-mouse / right-mouse (max. factor 2, min. factor 1)
    4545void MouseAPIExample::clickleft(MouseButtonCode::ByEnum mouse)
    4646{
    47      //MouseAPI::getInstance().changeRadiusOfClickableObject(cubeid,10);
    48     orxout() << "left" << "\n";
     47     // action after left-click
     48     if (mouse == MouseButtonCode::Left)
     49     {
     50         Vector3 scale = this->getScale3D();
     51         if (scale.z <= 2) this->setScale3D(scale.x,scale.y,scale.z+0.1);
     52     }
     53     // action after right-click
     54     else if (mouse == MouseButtonCode::Right)
     55     {
     56         Vector3 scale = this->getScale3D();
     57         if (scale.z > 1) this->setScale3D(scale.x,scale.y,scale.z-0.1);
     58     }
    4959}
    5060
    51 //
     61// scale the y-component up / down with left-mouse / right-mouse (max. factor 2, min. factor 1)
    5262void MouseAPIExample::clickright(MouseButtonCode::ByEnum mouse)
    5363{
    54      //MouseAPI::getInstance().changeRadiusOfClickableObject(cubeid,10);
    55     orxout() << "right" << "\n";
     64    // action after left-click
     65    if (mouse == MouseButtonCode::Left)
     66    {
     67        Vector3 scale = this->getScale3D();
     68        if (scale.y <= 2) this->setScale3D(scale.x,scale.y+0.1,scale.z);
     69    }
     70    // action after right-click
     71    else if (mouse == MouseButtonCode::Right)
     72    {
     73        Vector3 scale = this->getScale3D();
     74        if (scale.y > 1) this->setScale3D(scale.x,scale.y-0.1,scale.z);
     75    }
    5676}
    5777
     
    7595    else if(this->getId() == 3) // id == 3; long block
    7696    {
    77         // add the left and right outermost part of the long block to the list with clickable Objects and define clickleft/clickright to be called
    78         leftid = MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left,MouseButtonCode::Right},[this](MouseButtonCode::ByEnum mouse){this->clickleft(mouse);});
    79         rightid = MouseAPI::getInstance().addClickableObject(this->getWorldPosition(),10,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left,MouseButtonCode::Right},[this](MouseButtonCode::ByEnum mouse){this->clickright(mouse);});
     97        // add the left and right part of the long block to the list with clickable Objects and define clickleft/clickright to be called
     98        leftid = MouseAPI::getInstance().addClickableObject(Vector3(0,70,-70),20,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left,MouseButtonCode::Right},[this](MouseButtonCode::ByEnum mouse){this->clickleft(mouse);});
     99        rightid = MouseAPI::getInstance().addClickableObject(Vector3(0,70,70),20,std::list<MouseButtonCode::ByEnum>{MouseButtonCode::Left,MouseButtonCode::Right},[this](MouseButtonCode::ByEnum mouse){this->clickright(mouse);});
    80100    }
    81101
Note: See TracChangeset for help on using the changeset viewer.