Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2019, 4:05:35 PM (5 years ago)
Author:
mkarpf
Message:

example level weiterentwickelt
mousapi addobject korrigiert

File:
1 edited

Legend:

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

    r12306 r12311  
    3535    // set factor to 120% or 80% of the current size, depending on increase or decrease
    3636    float factor = curRadius/10*(1+rel/600.0);
     37    // return if factor is outside of range [0.5,5] (limit size)
     38    if(factor > 5 || factor < 0.5) return;
    3739    //scale the sphere with this factor and change the radius
    3840    this->setScale(factor);
    3941    MouseAPI::getInstance().changeRadiusOfScrollableElement(sphereid,factor*10);
     42}
     43
     44//
     45void MouseAPIExample::clickleft(MouseButtonCode::ByEnum mouse)
     46{
     47     //MouseAPI::getInstance().changeRadiusOfClickableObject(cubeid,10);
     48    orxout() << "left" << "\n";
     49}
     50
     51//
     52void MouseAPIExample::clickright(MouseButtonCode::ByEnum mouse)
     53{
     54     //MouseAPI::getInstance().changeRadiusOfClickableObject(cubeid,10);
     55    orxout() << "right" << "\n";
    4056}
    4157
     
    5773        sphereid = MouseAPI::getInstance().addScrollElement(this->getWorldPosition(), 10, [this](int abs, int rel, const IntVector2& mousePos){this->changesizeonscroll(abs,rel,mousePos);});
    5874    }
     75    else if(this->getId() == 3) // id == 3; long block
     76    {
     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);});
     80    }
    5981
    6082    // activate MouseAPI
Note: See TracChangeset for help on using the changeset viewer.