예제 #1
0
void GuiObject::touchesMoved(app::TouchEvent event){
    
    //Vec2f centroid;
    //int pntCnt=0;
    
        //Go Through all the touches in the event if the current touch is in the objects touch list then call the objects touches moved handler
        for( vector<TouchEvent::Touch>::const_iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) {
            //If the touch object has current touches, check if they are in this event. if so move/reposition object based on the updated touches.
            auto found=std::find_if (currentObjTouches.begin(),currentObjTouches.end(), FindTouch(*touchIt));
            if(found!=currentObjTouches.end() ){//this touch id is touching this object
                touchesMovedHandler();
                event.setHandled();

                // centroid += touchIt->getPos();
               // pntCnt++;
            }
          
        }
    /*
    if(this->oCanMove){
        centroid/=pntCnt;//Get the center/average point of the touches
        if(currentObjTouches.size()>0 && !isNaN(centroid) ){
            oContainer.offsetCenterTo(centroid);
        }
    }
    if(currentObjTouches.size()>0 && !oSelected)  setSelected(true);
*/


}
예제 #2
0
void GuiObject::touchesBegan(app::TouchEvent event){

        //Go Through each touch object and check if this object contains the point
        for( vector<TouchEvent::Touch>::iterator touchIt = event.getTouches().begin(); touchIt != event.getTouches().end(); ++touchIt ) {
            
            //if this object contains the point and this is the object is not sitting below any other object;
            if( oContainer.contains( touchIt->getPos()) &&// does this object contain the touch point
                objectOrderList.at(getTopMostObject(touchIt->getPos())) == this //is the topmost object and the current object the same
                ){
                
                    // if this object is accepting touches add the touch to the obj's touch list
                    if(oIsAcceptingTouches){
                        currentObjTouches.push_back(*touchIt);
                         event.setHandled( true );
                    }
                }
        }

    if(currentObjTouches.size()>0)        touchesBeganHandler();

}