Kind of. Research has shown that during a painful procedure — having a burn dressing changed, for instance — playing a video game, particularly a role-playing one, can lower the amount of pain a person feels. The game absorbs attention that would otherwise go to the discomfort.
What does not work is treating it as a painkiller you can take in advance. Play a game, put it down, and then hurt yourself, and it will hurt exactly as much as it normally would.