A court heard how police were faced with a hostile crowd in a Halifax street which goaded a distressed man who had climbed onto the roof of a house.