Cloudy with a Chance of Meatballs

The book “Cloudy with a Chance of Meatballs” has been delighting children for 31 years now with its tall tale of a town called Chewandswallow where it rains food. But readers have often wondered: How did the town come to be this way? What led to this bizarre change in the weather patterns? Was global warming involved?

No, I kid. No one has wondered this. Nonetheless, the animated “Cloudy with a Chance of Meatballs” film explains the origins of Chewandswallow’s peculiar precipitation, and darned if it isn’t a thoroughly enjoyable answer to a question nobody asked. Written and directed by the team of Phil Lord and Chris Miller (creators of MTV’s “Clone High”), “Cloudy” is almost relentlessly energetic and loony, bursting with random sight gags and subtle, whip-smart comedy. It’s only in the last act that it sags a little under the weight of its insane plot, but barely enough to hurt it.

On a small Atlantic island called Swallow Falls lives a would-be inventor named Flint Lockwood (voice of Bill Hader) who hopes to solve the town’s problems. You see, Swallow Falls was once the capital of the sardine industry, until the rest of the world realized that sardines are gross and stopped eating them. Now the locals are left with no major industry and, what’s worse, a surplus of sardines that they have no choice but to eat themselves. Everything in town is sardine-based.

Flint has built a machine that he thinks will turn water into food, which would fix the food problem and make the town world-famous to boot. Meanwhile, the fatuous mayor (Bruce Campbell) has spent all the town’s money on a sardine-based theme park, hoping to boost tourism and civic pride that way. Brent (Andy Samberg), who as an infant was the face of the town’s largest sardine company (think Gerber baby), doesn’t want to let sardinism go, either, since it’s his only claim to fame and he still lives off the royalties. Flint’s father, Tim (James Caan), runs a bait shop and thinks his son is weird.

Aided (sort of) by a monkey named Steve (Neil Patrick Harris) that’s been fitted with a device to translate his thoughts, Flint tests his food-making machine outdoors and accidentally launches it into the stratosphere. Next thing you know, it’s sucking in clouds and turning their precipitation into hamburgers (complete with condiments!). Thanks to news coverage by junior reporter Sam Sparks (Anna Faris) — a brilliant young woman who has to fake being dumb to fit in on TV news — Swallow Falls is soon internationally known. And the residents are thrilled to be eating so well! (Flint can control the machine from his laboratory and make it produce specific foods to order. The science there is not clear, but go with it.)

But never mind the story, and the complications that result when the town gets too greedy for more (and bigger) food. The film’s hilarity comes from its wide cast of ancillary characters, many of them nameless, who pop up to deliver an odd line or two then disappear again. I love the local cop (Mr. T), with bulging Popeye arms, who literally bounces all over town looking for criminals and can sense danger: “My chest hairs are tingling!” (He calls Flint a “shenaniganizer” and a “tomfool,” too, which makes him OK in my book.) There’s Steve the monkey, most of whose thoughts translate into simply saying his own name. There’s the shrewd satire of TV news, embodied by Sam’s condescending anchorman, Patrick Patrickson (Al Roker). The sight of Baby Brent clinging to the fame of his infancy by making public appearances and repeating his catchphrase is always funny. Flint and Sam’s nerdy romance is cute.

This is only the third film to come from Sony Pictures Animation, after “Open Season” and “Surf’s Up,” and it’s a huge step forward from those so-so efforts. The inventive, fast-paced humor is aimed at adults as much as kids but is accessible to everyone, and it’s sharp without being cynical. There’s also a sweet father-and-son story for Flint and his dad woven into the lunacy, to give the whole goofy affair just a little bit of weight. It’s a nice final touch on a very funny film.

A- (1 hr., 30 min.; PG, mild crude humor.)