Touch and Hold the screen as long as possible

Sorry if this question is asked before. Basically, I am trying to touch the screen using TouchBegan method and hold it as long as possible using a touchflag which is set ‘true’ and only set ‘false’ in TouchEnded. And the functionality after touch and hold is done in update(dt) method.
This works only for few seconds and after a while, the touchflag is set false by itself.
My main aim is to touch and hold as long as possible and perform the functionality inside the update() method.
Please help :slight_smile:

Hi. Are you sure? for my case it’s working and the touch flag system is a good method for handling control. I always use this and there is no issue.

Please provide your code. It allows folks to drop it into an empty project and test.

Sorry for the confusion, I am using multi touch inputs, so touchesBegan and touchesEnded methods.
Please check the code
void HelloWorld::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
{
for( auto &item: touches)
{
auto touch = item;
auto location = touch->getLocation();

    touchCount++;
    if(touch->getID() == 0){
        firstPoint = location;
    }
    if(touch->getID() == 1){
        secondPoint = location;
            touchFlag = 1;
    }
}

}

void HelloWorld::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
{
for( auto &item: touches)
{
auto touch = item;
auto location = touch->getLocation();

    if(touch->getID() == 0){

    }
    if(touch->getID() == 1){
        touchFlag = 0;
    }
}   

}

void HelloWorld::update( float delta) {
if(touchFlag != 0){
// The desired code after double touching the screen
}

}

Once we touch and hold for some time without moving our fingers the flow goes directly to touchesEnded and makes the touchFlag to 0.