In theory, a family film centred on a middle-aged man running round in his underwear sounds like a terrible idea.
But David Soren's computer-animated adaptation of Dav Pilkey's hit series of children's books avoids the pitfalls with enough success to amuse all ages.
It helps, to begin with, that the Captain himself isn't the hero.
As in the source material, that role belongs to fourth-graders George and Harold (voiced respectively by Kevin Hart and Thomas Middleditch), best friends and budding comic-book artists. This dynamic duo spend their time dreaming up adventures for the Captain - their absurd imaginary superhero - when they're not outraging their tyrannical principal Mr Krupp (Ed Helms) with elaborate pranks.
The film is presented as one of their fantasies, pushing cartoonish exaggeration as far as it will go: Mr Krupp's office allows him to dispatch victims by trapdoor and one bullied kid seems to live permanently in his locker.
Soren and his screenwriter Nicholas Stoller (Bad Neighbours) have a lot of self-conscious fun with storytelling devices, especially after George and Harold succeed in hypnotising Mr Krupp and get him to take on the Captain Underpants persona for real.
Of course, this transformation creates problems of its own, especially as the dimwitted Captain has trouble accepting that he can't fly.
The weakness, as in most of Stoller's family films - he also co-wrote the two most recent Muppet movies - is that the jokes are knowing to a fault.
But there's plenty of innocent vulgarity to make up for this, along with a disarmingly sentimental depiction of boyhood friendship (girls, as you might expect, don't get much of a look-in).
While bromances are everywhere in Stoller's work, this one is more satisfying than most, partly because he's able to do without most of the uneasy innuendo found in his adult work.
That said, the curious scene where George and Harold pledge eternal loyalty to each other makes this the second recent children's movie scripted by Stoller which might be taken as an oblique comment on same-sex marriage.